How link to a title in another document? - markup

I would like to link from within document A to Some Title in document B.
I know that I can do this within document B via 'Some Title'_
I know that I can reference document B from document A via :doc:'B'
Is there a way to combine both? (I tried combinations like :doc:'B/Some Title' but they did not work)
Note: the straight quote in the examples above should be a backtick but I do not know how to escape a backtick in the code mode.

Related

(Grafana Table) ${__cell} containing an apostrophe/single quote breaks the Query String to Kibana

In Grafana I've got a table panel which contains some names (one each row), that, if clicked, open a new window on Kibana passing via URL the name the user clicked (${__cell}) in order to Drill-Down that particular name.
This use to works fine, but I'm facing a problem when then name contains a special character such as "Identita' Digitale" (without double quote): as you can see it contains an apostrophe/single quote that breaks the query so the Kibana's URL becomes uncomplete.
Try
${__cell:lucene}
instead of
${__cell}
All special characters should be escaped for Lucene query. Actually, you need URL encode for your case - you may try other advanced formatting options.
Doc: http://docs.grafana.org/reference/templating/#advanced-formatting-options
Another dirty hackish solution, use JS to urlencode link in the onclick event, add this string at the end of your link definiton in the Grafana:
" onclick="location.href=encodeURI(this);
So in full HTML it will create link:
<a href="<URL>" onclick="location.href=encodeURI(this);">...
Syntax in my example can be wrong, it may need some minor changes to work properly. You can use jQuery in theory.

bash: how to make a clickable link with query parameters?

I am trying to dump url on the terminal that needs to be clickable, and the url comes with a query parameter. For example --
google='https://www.google.com/search?q='
orgname='foo bar'
gsearch=$google\'$orgname\'
echo "details: $orgname ($gsearch)"
But the problem is that the clickable link totally omits everything after the q=, i.e. does not include the string 'foo bar', please see the image below --
How do I make a clickable link that includes the query (i.e. the whole url in the braces above)?
Please also note that I am adding quote in the search parameter since the it may contain spaces.
Single quotes are not valid in URLs. Use the URL encoding %27 instead:
google='https://www.google.com/search?q='
orgname='foo'
gsearch=$google%27$orgname%27
echo "details: $orgname ($gsearch)"
Note that it's the terminal and not your script that decides what's considered part of a URL for the purpose of selecting or clicking. The above results in
https://www.google.com/search?q=%27foo%27
which is more clickable in most terminals. The script can't specify what's the extent of the URL except through expressing it in such a standard way that each individual terminal emulator has a decent chance of recognizing it.
PS: I don't think Google cares about surrounding single quotes.

Processing form input in a Joomla component

I am creating a Joomla component and one of the pages contains a form with a text input for an email address.
When a < character is typed in the input field, that character and everything after is not showing up in the input.
I tried $_POST['field'] and JFactory::getApplication()->input->getCmd('field')
I also tried alternatives for getCmd like getVar, getString, etc. but no success.
E.g. John Doe <j.doe#mail.com> returns only John Doe.
When the < is left out, like John Doe j.doe#mail.com> the value is coming in correctly.
What can I do to also have the < character in the posted variable?
BTW. I had to use & lt; in this question to display it as I want it. This form suffers from the same problem!!
You actually need to set the filtering that you want when you grab the input. Otherwise, you will get some heavy filtering. (Typically, I will also lose # symbols.)
Replace this line:
JFactory::getApplication()->input->getCmd('field');
with this line:
JFactory::getApplication()->input->getRaw('field');
The name after the get part of the function is the filtering that you will use. Cmd strips everything but alphanumeric characters and ., -, and _. String will run through the html clean tags feature of joomla and depending on your settings will clean out <>. (That usually doesn't happen for me, but my settings are generally pretty open to the point of no filtering on super admins and such.
getRaw should definitely work, but note that there is no filtering at all, which can open security holes in your application.
The default text filter trims html from the input for your field. You should set the property
filter="raw"
in your form's manifest (xml) file, and then use getRaw() to retrieve the value. getCmd removes the non-alphanumeric characters.

Yahoo pipes: how can I add an additional nodes/elements to RSS/feed items

I am merging two feeds using Yahoo pipes and using the output feed on a website. However, as would like to identify the "feed source" for each item in the output feed. Is it possible to manipulate the original feeds so I can add another node/element to the feed items?
Thanks
One way to do that is using the Regex operator. Let's say you want to add a new field called source. You could use Regex with parameters:
In: item.source
replace: .*
with: (the text you want)
See it in action here:
http://pipes.yahoo.com/janos/7a3b9993cfc143d414fe7b637b1bd95a
That is, I have two feeds, I added a source attribute in the first with value "Question 1" and in the second with value "Question 2".
As an added bonus interesting undocumented Yahoo Pipes hack, I used one more Regex after the Union to make the source appear in the title.
However, this only adds the attribute to the node in the pipe debugger. You can use it for further processing, like I added it here to the title, it won't create a <source> tag in the output. That's because the RSS output of Yahoo Pipes removes all other fields that are not in the RSS standard. You can still see it in the JSON output though.

Trouble using Xpath "starts with" to parse xhtml

I'm trying to parse a webpage to get posts from a forum.
The start of each message starts with the following format
<div id="post_message_somenumber">
and I only want to get the first one
I tried xpath='//div[starts-with(#id, '"post_message_')]' in yql without success
I'm still learning this, anyone have suggestions
I think I have a solution that does not require dealing with namespaces.
Here is one that selects all matching div's:
//div[#id[starts-with(.,"post_message")]]
But you said you wanted just the "first one" (I assume you mean the first "hit" in the whole page?). Here is a slight modification that selects just the first matching result:
(//div[#id[starts-with(.,"post_message")]])[1]
These use the dot to represent the id's value within the starts-with() function. You may have to escape special characters in your language.
It works great for me in PowerShell:
# Load a sample xml document
$xml = [xml]'<root><div id="post_message_somenumber"/><div id="not_post_message"/><div id="post_message_somenumber2"/></root>'
# Run the xpath selection of all matching div's
$xml.selectnodes('//div[#id[starts-with(.,"post_message")]]')
Result:
id
--
post_message_somenumber
post_message_somenumber2
Or, for just the first match:
# Run the xpath selection of the first matching div
$xml.selectnodes('(//div[#id[starts-with(.,"post_message")]])[1]')
Result:
id
--
post_message_somenumber
I tried xpath='//div[starts-with(#id,
'"post_message_')]' in yql without
success I'm still learning this,
anyone have suggestions
If the problem isn't due to the many nested apostrophes and the unclosed double-quote, then the most likely cause (we can only guess without being shown the XML document) is that a default namespace is used.
Specifying names of elements that are in a default namespace is the most FAQ in XPath. If you search for "XPath default namespace" in SO or on the internet, you'll find many sources with the correct solution.
Generally, a special method must be called that binds a prefix (say "x:") to the default namespace. Then, in the XPath expression every element name "someName" must be replaced by "x:someName.
Here is a good answer how to do this in C#.
Read the documentation of your language/xpath-engine how something similar should be done in your specific environment.
#FindBy(xpath = "//div[starts-with(#id,'expiredUserDetails') and contains(text(), 'Details')]")
private WebElementFacade ListOfExpiredUsersDetails;
This one gives a list of all elements on the page that share an ID of expiredUserDetails and also contains the text or the element Details

Resources