Generating an external link in Sphinx - hyperlink

I'd like to link to some URL in my Sphinx docs:
blah
I have found something similar in the docs: http://sphinx-doc.org/ext/extlinks.html - but it is rather about replacing the custom syntax with the link, by convention. Instead, I just want to generate a link to external web resource.

See the reStructuredText documentation. It can be done either with a named reference:
Test hyperlink: SO_.
.. _SO: https://stackoverflow.com/
Or with:
Test hyperlink: `Stack Overflow home <SO>`_.
.. _SO: https://stackoverflow.com/
Or with an embedded URI:
Test hyperlink: `Stack Overflow home <https://stackoverflow.com/>`_.

Related

Wordpress Custom Post Type Search URL

Currently Wordpress produces this URL when searching for something on a website
websitename.com/?s=tools
I want to be able to have search links for a custom post type. The search itself wont be public but I will essentially be listing links to search:
Click Here For More Tools
this would be the url I can simply change the search query with
websitename.com/?s=[insert custom post type name here]tools
Is it possible to produce a url like above which only return results from a custom post type?
Thank you
This is an old question but maybe it will help others looking for something similar. The URL structure for your wordpress site should be like this: http://example.com/?s=my-search-string&post_type=custom-post-slug
All the best

W3C validator says 'feed does not validate' 'url must be a full URL'... whats wrong with it?

Validating my feed, it has an enclosure with a URL of
https://archive.org/download/NigelFarageAPersonalMessageToNorthernIrelandVoters./Nigel%20Farage,%20a%20personal%20message%20to%20Northern%20Ireland%20voters..mp3
I know it is a bit convoluted... but what is wrong with it? The stop in the directory name? the double dot in the file name? the comma? all of em?
I have looked at the RFC on URL's but cant make it out(!).
This feed does not validate.
line 441, column 2: url must be a full URL: https://archive.org/download/NigelFarageAPersonalMessageToNorthernIrelandVoters./Nigel%20Farage,%20a%20personal%20message%20to%20Northern%20Ireland%20voters..mp3 (4 occurrences) [help]
<enclosure type="audio/mpeg" url="https://archive.org/download/NigelFarage ...
^
** edit **
A useful (even if incorrect) answer was added (and removed...) showing the result from the w3c URL validator - https://validator.w3.org/checklink
This Link Checker looks for issues in links, anchors and referenced objects in a Web page, CSS style sheet, or recursively on a whole Web site. For best results, it is recommended to first ensure that the documents checked use Valid (X)HTML Markup and CSS. The Link Checker is part of the W3C's validators and Quality Web tools.
If you find this question, you may find the link checker a useful resource!
The problem seems to be that it’s a HTTPS URL instead of a HTTP URL.
The linked error documentation, foo attribute of bar must be a full URL, says:
If this is a link to a web page, you must include the "http://" at the beginning and immediately follow it with a valid domain name.
The RSS 2.0 spec says about <enclosure>:
The url must be an http url.
If you change https://archive.org/download/… to http://archive.org/download/…, it validates.
And if you don't have httpS then your SSL says your page isn't secure. #feedvalidator step up. There are a ton of feedback/complaints about this on the support forum here https://groups.google.com/forum/#!forum/feedvalidator-users
More specifically here: https://github.com/rubys/feedvalidator/issues/16

Creating a dynamic hyperlink in Word with XDocReport

I need to create a hyperlink using XDocReport where both the URL and display name are provided using Velocity tags. There is some reference to this on the XDocReport web site, but no real guidance.
Other things I have tried, like http://blog.softartisans.com/2013/12/31/kb-creating-dynamic-links-with-mergefields-in-microsoft-word/, do not work.
Manage hyperlink with XDocReport is like mergefield. XDocReport wiki page about hyperlink with docx can be found here, but I agree, it should be improved.
If you cannot manage hyperlink with XDocReport and docx, I suggest :
use the XDocReport macro . There is a link checkbox to insert hyperlink instead of inserting mergefield.
download docxandvelocity-XXX-sample.zip or get Git project fr.opensagres.xdocreport.samples.docxandvelocity. You will find samples with hyperlinks.
Based on #MarkSalamon suggested link: http://blog.softartisans.com/2013/12/31/kb-creating-dynamic-links-with-mergefields-in-microsoft-word/ , it failed in my case too.
After debugging the opensagres library, it seems that instead of inserting a merge field inside the Hyperlink, the library is expecting there just a simple Freemarker placeholder. So it's enough to create the hyperlink from Word, and at the url definition part, you can specify there: ${url} .
That's it, the library is going to detect that there is a Freemarker syntax and replace the url with back-end data. So you don't have to do the trick with ALT+F9 and replace with merge field codes.
In my case this worked with opensagres version: 2.0.2

Interpreting a Relative path in a URL

I'm writing a 'webcrawler' in python that takes a URL and does a depth-first search following links down to some limited depth. The problem I'm having is interpreting relative paths in URLS.
On the page http://learnyouahaskell.com/introduction/ have a look at the "Starting Out" link; it looks like Starting Out. How can I determine whether this link refers to "http://learnyouahaskell.com/introduction/starting-out" or "http://learnyouahaskell.com/starting-out"? The second one is correct according to my browser.
Yet on the page http://math.colgate.edu/~mionescu/math399s11/ there is a link here which resolves to "http://math.colgate.edu/~mionescu/math399s11/Finalprojects.pdf".
Can someone explain this inconsistency to me? How can I determine how these paths should be resolved in my crawler?
The reason for this 'apparent' inconsistency is that the learnyouahaskell site is using the <base href=""> tag in their source. This directs all domainless hrefs to use the base as their starting point.
Without the base tag it would have appeared as expected (the first link you post) and acted just like the math.colgate.edu link.

dynamic seo title for news articles

I have a news section where the pages resolve to urls like
newsArticle.php?id=210
What I would like to do is use the title from the database to create seo friendly titles like
newsArticle/joe-goes-to-town
Any ideas how I can achieve this?
Thanks,
R.
I suggest you actually include the ID in the URL, before the title part, and ignore the title itself when routing. So your URL might become
/news/210/joe-goes-to-town
That's exactly what Stack Overflow does, and it works well. It means that the title can change without links breaking.
Obviously the exact details will depend on what platform you're using - you haven't specified - but the basic steps will be:
When generating a link, take the article title and convert it into something URL-friendly; you probably want to remove all punctuation, and you should consider accented characters etc. Bear in mind that the title won't need to be unique, because you've got the ID as well
When handling a request to anything starting with /news, take the next part of the path, parse it as an integer and load the appropriate article.
Assuming you are using PHP and can alter your source code (this is quite mandatory to get the article's title), I'd do the following:
First, you'll need to have a function (or maybe a method in an object-oriented architecture) to generate the URLs for you in your code. You'd supply the function with the article object or the article ID and it returns the friendly URL with the ID and the friendly title.
Basically function url(Article $article) => URL.
You will also need some URL rewriting rules to remove the PHP script from the URL. For Apache, refer to the mod_rewrite documentation for details (RewriteEngine, RewriteRule, RewriteCond).

Resources