I'm building a site with Wagtail and using StreamField to build up content on a homepage. I've built a block that allows users to add featured links, which could be internal or external links. Currently the featured links have both a PageChooserBlock and a URLBlock, but I'd like to add a new custom block type that allows a user to specify either an internal page or a URL. I can't see anything in the docs that would help me. Any ideas where to start?
This is nothing Wagtail supports yet, but there's a lot of interest in this feature, see issue https://github.com/wagtail/wagtail/issues/3141.
To solve this there is a pull request work in progress (see https://github.com/wagtail/wagtail/pull/1645) that aims to unify link choosers.
Maybe you are able to contribute, I'm sure this would be very welcome!
you can use this library: https://pypi.org/project/wagtail-link-block/
From the docs:
"A link block to use as part of other StructBlocks which lets the user choose a link either to a Page, Document, or external URL, and whether or not they want the link to open in a new window."
Related
I'm creating a "data catalog" on SharePoint that consists of a page of links to other pages. Objects are clickable and take the user to a page where related Attributes are listed. (I know that I'd be better off using data cataloging software, but it's a non-starter atm.)
I know that SharePoint has a "search box" web part, but it's apparently available for classic view only, and we are using modern view (and can't change to classic.) I really need a search box web part. Is this possible? I'm python-literate so if I could code something using python or something comparable, I probably could.
Anybody else solved this issue?
You could use SharePoint Framework modern search Web Parts in modern page.
Get to know about SharePoint Framework(SPFx)
In Django whenever I have to use site navigation I use the Reverse resolution of URLs. This way I can make django -render- each new html page and pass that page whatever arguments I want to through the views.
However I am wondering how should I do this in web.py. For instance, I have a web.py template that contains a variable $user. At some point in the main webpage a simple button contains a link of the form
Account
which redirects a user to his account page. Now, I need to pass $user on to account.html so that he/she can change his/her details. The problem is that since I can't directly link to account.html cause it's not a static page, how should I go through web.py and use its render method?
Thanks in advance.
It seems to me that the best way to do this would be with a session variable. That kind of variable can be consistent across several pages.
I have a website that gets a lot of links to youtube and similar sites and I wanted to know if there is anyway that I can make a link automatically appear as a video. Like what happens when you post a link to a video on facebook. You can play it right on the page. Is there a way to do this without users actually posting the entire embed video HTML code?
By the way I am using google app engine with python and jinja2 templating.
Each youtube video has a unique ID which is present in the url.
Examples here:
http://www.youtube.com/watch?v=DU0Q0U08gAc&feature=g-all-esi
http://youtu.be/DU0Q0U08gAc
In this case, DU0Q0U08gAc is the movie id.
This just gets inserted in the embed tag, as you can see here:
<iframe width="560" height="315" src="http://www.youtube.com/embed/DU0Q0U08gAc" frameborder="0" allowfullscreen></iframe>
So you need to parse the url for the id and insert it to an embed tag. I believe that in the case of youtu.be style links, it's just whatever's after the '/', and in the case of youtube.com links it's probably best practice to use the urlparse library to get the 'v' variable from the url's query string. Hopefully someone will chime in if there's a corner case I'm not aware of.
Your solution is Micawber...which is available in pure Python, as well as Django and Flask plugins. Works nicely with Jinja. Embeds vids and pics into your app exactly like Facebook. You can install it via pip. Good docs; easy to follow examples. The author is responsive to questions. Works great, and it's totally free. Check it out:
http://readthedocs.org/projects/micawber/
You can also check out http://oembed.com and http://embed.ly ...although the latter is not free, and starts at $19/mo (as of July 2012).
Use this code when getting embed link from list value. In the template inside the iframe use below code
src="{{results[0].video_link}}"
"video_link" is the Field name.
What I'm looking for, should give me something like this ->
There are many APIs available that can accomplish your task (more precisely the task you describe on your question, not the image :) ). I personally use diffbot, which I discovered after reading this. Beware though, for this kind of "content" extraction does not always end with success, because of the nature of web pages. Instead, it relies on heuristics and training and thus may not suffice for your specific purposes...
If you're wanting an entire screenshot of the page then something like https://stackoverflow.com/questions/1041371/alexa-api may help you?
Otherwise if you're just wanting to get a few key images from the page..
you could use mechanize to assit you. When you connect to a webpage you can search through all the links on the page using:
for link in br.links():
where br is your browser object.
You can see an example here:
Download all the links(related documents) on a webpage using Python
if you print dir(link) it will show you various properties such as link.text and link.url. furthermore you can import urlparse.urlsplit and use it on the url. You can direct the browser towards the URL and scrape the images as shown in the above example.
You should really use a search engines interpretation of the page and the images in it.
You could use, the python wrapper on the bing API, or the xGoogle library.
Beware the xGoogle library fakes to google as if a browser and may not be endorsed way to consume Google's data.
This one should help: http://palewi.re/posts/2008/04/20/python-recipe-grab-a-page-scrape-a-table-download-a-file/
Learns you how to scrape content and images and store it.
I'm using Hudson to generate the documentation for a Python project using Sphinx. This generates HTML documentation in the folder project/_build/html, which I set up to be used as an build artifact. Now after running the job, I can navigate to the documentation by clicking on the "Artifacts" link, then on the folder, and then on the index.html file. That's a bit cumbersome so I would like to customize the project page so I can have a "View Documentation" link that takes me straight to the index.html file. Is there any way to do that with hudson?
I know the question is closed, but I thought you could try this. You don't need a separate http server just to serve HTML documentation, artifact or not. You can use the plugin:
http://wiki.hudson-ci.org/display/HUDSON/HTML+Publisher+Plugin
The Project Description allows HTML, just edit it and place the link to your docs from the last successful build.
Get the sidelink plugin. That let's you add a link to the ones that are on the left-hand side of the project page.