Embed media content on lektor pages?

I am currently using Nikola as a page generator.

But depending on the area of ​​the page and the users, Lektor seems to be simpler and more simplified for the end user. This works well for the new page I'm planning.

Nikola also introduces media (youtube, vimeo, soundcloud, etc.) https://getnikola.com/handbook.html#restructuredtext-extensions

How is such functionality provided by Lektor?

+5
source share
3 answers

Answer @A. Jesse is right. Due to the simplicity of the core, Lektor , like t21, does not automatically embed the kernel.

However, in the same spirit of Flask , Lektor is very extensible. This also applies to its MarkDown formatted text in the message and rendering the final HTML.

As he said, you can directly embed embed code in HTML in your other MarkDown texts. And it will be included as-is in the final HTML.

But, personally, I thought that it harmed the basic intention of the simple and quick readability of MarkDown.

easy to read, easy to use text format

This is why I felt the need for lektor-embed-x , where the writer simply writes the link to the content in a separate paragraph. This small piece of the plugin will do its best. It is basically a glue library between embedX and Lektor .

  • If the content is a relatively β€œpopular” site and the link is fine, you must create the appropriate inline code and include it in the final HTML.
  • If not, the link will lead to a regular link, i.e. to <a href=...

The use is very simple.

step 1 Add the plugin: $ cd path/to/lektor/project_folder $ lektor plugins add lektor-embed-x Package lektor-embed-x (0.1.2) was added to the project

What is it. You are ready to go. [There is currently no add configuration.]

Now in the message, you can add a link to the paragraph of your paragraph without any special marker or start flag in your formatted MarkDown column, as shown below.

contents.lr

 title: About this Website --- body: This is a website that was made with the Lektor quickstart. And it does not contain a lot of information. # **HEADING 1** ## 2nd head _italic slated text_ ~~mess~~ whatever text i need to write. https://twitter.com/codinghorror/status/686254714938200064 Below is how I can embed in a post. http://www.youtube.com/watch?v=_lOT2p_FCvA So, that was what i wanted to say. 

After creating the final HTML using Lektor , the above entry will create something like:

sample render

Note

Please note that this is a very nascent individual project, which is under active development, and only from the preliminary alpha phase. Consequently, there are not many providers or link formats. Yet. But I hope he soon becomes mature.

+6
source

He is not yet represented in the Lecturer. Typically, with Lektor you write your content in Markdown. You can simply paste the HTML embed code (from YouTube or any other service) directly into your Markdown. But there is a newly released plugin called lektor-embed-x that can do what you want.

+4
source

If you agree to the use of streams, you can, of course, also define stream blocks for your media. It also allows you to control the management using the options displayed in the administrator. For example, a very simple (faceless) youtube stream block might look like this:

flowblocks / youtube.ini:

 [block] name = Youtube button_label = Youtube Video [fields.ytid] label = Video ID type = string width = 1/2 

Templates / Blocks / youtube.html:

 <iframe width="560" height="315" src="https://www.youtube.com/embed/{{this.ytid}}" frameborder="0" allowfullscreen></iframe> 

This defines a new block type called "Youtube Video" with the internal name "youtube". The user must enter the youtube video identifier (letters / numbers after? V = in the video), which is then used in the template using the this.ytid link.

With this technology, you can also add many additional options. The following is an almost complete description.

flowblocks / youtube.ini:

 [block] name = Youtube button_label = Youtube Video [fields.ytid] label = Video ID type = string width = 1/2 [fields.size] label = Video size type = select choices = 560x315, 640x360, 853x480, 1280x720 choice_labels = 560 x 315, 640 x 360, 853 x 480, 1280 x 720 default = 560x315 width = 1/2 [fields.rel] label = Show suggested videos when the video finishes type = boolean default = true width = 1/4 [fields.controls] label = Show player controls type = boolean default = true width = 1/4 [fields.showinfo] label = Show video title and player actions type = boolean default = true width = 1/4 [fields.nocookie] label = Enable privacy-enhanced mode type = boolean width = 1/4 

Templates / Blocks / youtube.html:

 <iframe width="{{ this.size.split("x")[0] }}" height="{{ this.size.split("x")[1] }}" src="https://www.youtube{{ "-nocookie" if this.nocookie }}.com/embed/{{this.ytid}}?{{ "rel=0&" if not this.rel}}{{ "controls=0&" if not this.controls }}{{ "showinfo=0" if not this.showinfo }}" frameborder="0" allowfullscreen></iframe> 

Then it will look when editing in admin: Effective Admin User Interface

Perhaps some smart regex can be used to let the user paste in the full YouTube URLs, so they don’t have to retrieve the video id manually. But I have not tried it yet.

+3
source

Source: https://habr.com/ru/post/1241366/


All Articles