I'm currently migrating a Wordpress blog to Contentful. During that migration I want to transform urls, e.g. https://www.youtube.com/watch?v=psil6MKUXeE, into embeds.
Let's say I got this text:
Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.
https://www.youtube.com/watch?v=psil6MKUXeE
Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio.
https://www.youtube.com/watch?v=psil6MKUXeE
Dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi. Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat.
How can I extract multiple urls (in this case youtube) and replace them with the youtube embed code?
If I understand your question correctly, you want to replace https://www.youtube.com/watch?v=video_id with an iframe that holds your video.
You can do something like this:
url = 'https://www.youtube.com/watch?v=psil6MKUXeE'
value = url.match(/v=(.*)$/)[1]
target = "<iframe width='854' height='480' src='https://www.youtube.com/embed/#{value}' frameborder='0' allow='autoplay; encrypted-media' allowfullscreen></iframe>"
This will generate the links in the embeded video format that you want, implementing a script is a bit hard with the information you've provided, but putting this inside a loop that contains files and the lines to be replaced should no be hard. If you're working on Linux, you could even do this with sed on the whole repository.
TEXT = 'your text with links to youtube videos'
url_regex = /https:\/\/www.youtube.com\/watch\?v=(\w+)/
iframe_tag = '<iframe width="560" height="315" src="https://www.youtube.com/embed/\1?rel=0" frameborder="0" allow="autoplay; encrypted-media" allowfullscreen></iframe>'
TEXT.gsub(url_regex, iframe_tag)
regex could be simplified to something like /https.+?v=(\w+)/ if all links in text goes to youtube.
you should change iframe_tag params to fit your requirments on autoplay, sizes etc.
Related
Code example:
create_data_with(
first: "Lorem ipsum dolor sit amet, consectetur adipiscing elit.",
second: <<~TEXT
Aenean vel ex bibendum, egestas tortor sit amet, tempus lorem. Ut sit
amet rhoncus eros. Vestibulum ante ipsum primis in faucibus orci
luctus et ultrices posuere cubilia curae; Quisque non risus vel lacus
tristique laoreet. Curabitur quis auctor mauris, nec tempus mauris.
TEXT,
third: "Nunc aliquet ipsum at semper sodales."
)
The error is present in this line:
second: <<~TEXT
RuboCop describes it like this:
Lint/Syntax: unterminated string meets end of file
(Using Ruby 3.1 parser; configure using TargetRubyVersion parameter, under AllCops)
second: <<~TEXT
Can you please tell me what should be the syntax? I need to keep the look and use of <<~.
Another option is to move the heredoc after the method call. However, since the heredoc starts on the line following its identifier, your method call must not span multiple lines:
create_data_with(first: "foo", second: <<~TEXT, third: "bar")
Aenean vel ex bibendum, egestas tortor sit amet, tempus lorem. Ut sit
amet rhoncus eros. Vestibulum ante ipsum primis in faucibus orci
luctus et ultrices posuere cubilia curae; Quisque non risus vel lacus
tristique laoreet. Curabitur quis auctor mauris, nec tempus mauris.
TEXT
For longer values, you could use multiple heredocs:
create_data_with(first: <<~FIRST, second: <<~SECOND, third: <<~THIRD)
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
FIRST
Aenean vel ex bibendum, egestas tortor sit amet, tempus lorem. Ut sit
amet rhoncus eros. Vestibulum ante ipsum primis in faucibus orci
luctus et ultrices posuere cubilia curae; Quisque non risus vel lacus
tristique laoreet. Curabitur quis auctor mauris, nec tempus mauris.
SECOND
Nunc aliquet ipsum at semper sodales.
THIRD
With heredocs, the parser expects the exact delimiter to close the literal. You open with TEXT, but you close with TEXT, and ruby doesn't consider this literal closed. However, you can (and should in this case) put the comma after the opening delimiter. Here's a fix:
create_data_with(
first: "Lorem ipsum dolor sit amet, consectetur adipiscing elit.",
second: <<~TEXT,
Aenean vel ex bibendum, egestas tortor sit amet, tempus lorem. Ut sit
amet rhoncus eros. Vestibulum ante ipsum primis in faucibus orci
luctus et ultrices posuere cubilia curae; Quisque non risus vel lacus
tristique laoreet. Curabitur quis auctor mauris, nec tempus mauris.
TEXT
third: "Nunc aliquet ipsum at semper sodales."
)
You can even call methods this way. For example, the squiggly heredoc (<<~TEXT) was previously done in rails as <<-TEXT.strip_heredoc
My problem is the representation of long {chapter-title} in the header area. The long chapter titles overlaps the company logo. It would be great if I could define a short version for the header area.
I'm using the asciidoctor-maven-plugin version 2.2.1 and asciidoctorj-pdf-plugin version 1.6.0 for pdf creation. The theme.yml has following definitions:
recto:
left:
content: '{document-title}'
right:
content: image:logo.png[width=200]
verso:
left:
content: '{chapter-title}'
right:
content: $header-recto-right-content
and example.adoc looks as folows:
= Lorem ipsum dolor sit amet
:doctype: book
:encoding: utf-8
:lang: en
:toc: macro
:toclevels: 2
:numbered:
toc::[]
== Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet
Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.
Use the <side>-columns property to assign a specific width for your header elements. Check Running Content (Header & Footer) for more info.
header:
recto:
columns: <25% =50% >25%
left:
content: '{document-title}'
right:
content: image:logo.png[width=200]
I'm new to joomla and I have a problem in adding title of articles in read more button using TAG ITEMS.
I have two articles like this:
Lorem Ipsum
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque quis elit augue. Aliquam mattis sem sed ligula mattis faucibus. Donec vitae pretium sem. Vivamus ipsum enim...
Read More
Dolor Sit amet
Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Maecenas purus ex, ultrices eget ante ac, tempor suscipit nunc. Etiam viverra dolor id...
Read More
=========================================================================
What i want to do is add the title of each article to the readmore button, so it would look like this:
Lorem Ipsum
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque quis elit augue. Aliquam mattis sem sed ligula mattis faucibus. Donec vitae pretium sem. Vivamus ipsum enim...
Read More: Lorem Ipsum
Dolor sit amet
Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Maecenas purus ex, ultrices eget ante ac, tempor suscipit nunc. Etiam viverra dolor id...
Read More: Dolor sit amet
Can anyone help me with this problem?
Thanks!
In Content -> Articles -> Options, set "Show Title with Read More" = "Show".
The Full error.
Fatal error: Allowed memory size of 805306368 bytes exhausted (tried to allocate 10015 bytes) in /home/mvcolleg/public_html/plugins/system/tcshortcodes/core/tc_shtcodes.php on line 152
Well I only use these in my articles but this item is link on my JU Flashnews.
Here is my code:
[row][col class="span6"] [tab id="tab2" class="tabbale" button="nav-tabs"] [tab_item title="Book Information"]
Leviticus: Brazos Theological Commentary on the Bible
Author:
EPHRAIM RADNER
Publisher:
Anvil Publishing Inc.
Format:
Book Bound
ISBN:
97897127336423
[accordion id="sc-accordion" class="accordion"][accordion_item title='About the Author']consectetur adipiscing elit. Proin ornare consectetur sodales. Nulla luctus cursus mauris at dapibus. Cras ac felis et neque consequat elementum a eget turpis. Aliquam erat volutpat. Integer feugiat sem eu ligula vulputate consequat. Nulla facilisi. Cras vel elit lectus, at fringilla lorem.[/accordion_item]
[accordion_item title='Student Reviews'][testimonial name="Oscar Vidal" designation=" System Administrator" email="email#email.com" url="#"]
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
Aliquam laoreet sodales lacinia. Curabitur ut purus tincidunt. Ipsum dolor sit amet, consectetur adipiscing laoreet sodales lacinia ut purus. Anime con saed elitr, sed diam nonu eirmo conse tetur sadipscing elitr.
[/testimonial]
[testimonial name="Jeriel Espenorio" designation=" System Administrator" email="email#email.com" url="#"]
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
Aliquam laoreet sodales lacinia. Curabitur ut purus tincidunt. Ipsum dolor sit amet, consectetur adipiscing laoreet sodales lacinia ut purus. Anime con saed elitr, sed diam nonu eirmo conse tetur sadipscing elitr.
[/testimonial][/accordion_item]
[accordion_item title='External Links and Other Sources'] Proin ornare consectetur sodales. Nulla luctus cursus mauris at dapibus. Cras ac felis et neque consequat elementum a eget turpis. Aliquam erat volutpat. Integer feugiat sem eu ligula vulputate consequat. Nulla facilisi. Cras vel elit lectus, at fringilla lorem.[/accordion_item] [/accordion][/tab_item]
[tab_item title="Description"] This volume, like each in the Brazos Theological Commentary on the Bible, is designed to serve the church--through aid in preaching, teaching, study groups, and so forth--and demonstrate the continuing intellectual and practical viability of theological interpretation of the Bible.[/tab_item]
[tab_item title="Gallery"][carousel]
[carousel_item]
Full Cover Page
[/carousel_item]
[carousel_item]
Full Cover Page
[/carousel_item]
[/carousel][/tab_item][/tab] [/col] [/row]
And then I've got this error it seems annoying that I'm happy and contented what I've done then I've got an error since I only use the visual Editor..
Kindly help me with this problem. I'm a newbie in Joomla and I'm using it for 3 days.
I solve it, by writing down a line in "configuration.php" and "configuration.php-dist":
ini_mem('memory_limit','12M');
Try this ;)
I have a new client that has an older 1.5 Joomla site. I don't have much experience with Joomla but I have been able to update it so far. There is a testimonial in a module in the right sidebar. If I add several testimonials they will just continue down the right side. This will create a very long homepage instead of rotating. I know it rotated before but the code was deleted...:(
I know it something very simple but I just have that much experience with Joomla and no one here can help..
Here is what I have
<p>11/26/13</p>
<p><i>“Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam non quam vitae sapien egestas posuere. Nam laoreet lacus in diam bibendum cursus. Phasellus nec commodo enim, vitae aliquam lacus. Nunc ultrices odio vel rutrum elementum. Duis sit amet massa ut nunc suscipit adipiscing at quis ipsum. Donec porta aliquam enim, sed congue nisi placerat et. Curabitur vel porta sem, sed ultrices tellus. Fusce malesuada pulvinar purus a facilisis. Ohio to Texas</i></p><br>Read More...<br mce_bogus="1">
You can install this module:
http://www.dynatec.at/joomla-extensions-modules-plugins-components/content-slider-module-for-joomla-1-5
I have an example here on this site:
http://five-elements-sd.com/center
I did some custom styling to it.