activated video filter and making it to work;
finded the way to call Drupal.behaviors after custom ajax : Drupal.attachBehaviors(context)
This commit is contained in:
@@ -0,0 +1,3 @@
|
|||||||
|
**/.DS_Store
|
||||||
|
**/.sass-cache
|
||||||
|
|
||||||
@@ -0,0 +1,339 @@
|
|||||||
|
GNU GENERAL PUBLIC LICENSE
|
||||||
|
Version 2, June 1991
|
||||||
|
|
||||||
|
Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
|
||||||
|
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
Everyone is permitted to copy and distribute verbatim copies
|
||||||
|
of this license document, but changing it is not allowed.
|
||||||
|
|
||||||
|
Preamble
|
||||||
|
|
||||||
|
The licenses for most software are designed to take away your
|
||||||
|
freedom to share and change it. By contrast, the GNU General Public
|
||||||
|
License is intended to guarantee your freedom to share and change free
|
||||||
|
software--to make sure the software is free for all its users. This
|
||||||
|
General Public License applies to most of the Free Software
|
||||||
|
Foundation's software and to any other program whose authors commit to
|
||||||
|
using it. (Some other Free Software Foundation software is covered by
|
||||||
|
the GNU Lesser General Public License instead.) You can apply it to
|
||||||
|
your programs, too.
|
||||||
|
|
||||||
|
When we speak of free software, we are referring to freedom, not
|
||||||
|
price. Our General Public Licenses are designed to make sure that you
|
||||||
|
have the freedom to distribute copies of free software (and charge for
|
||||||
|
this service if you wish), that you receive source code or can get it
|
||||||
|
if you want it, that you can change the software or use pieces of it
|
||||||
|
in new free programs; and that you know you can do these things.
|
||||||
|
|
||||||
|
To protect your rights, we need to make restrictions that forbid
|
||||||
|
anyone to deny you these rights or to ask you to surrender the rights.
|
||||||
|
These restrictions translate to certain responsibilities for you if you
|
||||||
|
distribute copies of the software, or if you modify it.
|
||||||
|
|
||||||
|
For example, if you distribute copies of such a program, whether
|
||||||
|
gratis or for a fee, you must give the recipients all the rights that
|
||||||
|
you have. You must make sure that they, too, receive or can get the
|
||||||
|
source code. And you must show them these terms so they know their
|
||||||
|
rights.
|
||||||
|
|
||||||
|
We protect your rights with two steps: (1) copyright the software, and
|
||||||
|
(2) offer you this license which gives you legal permission to copy,
|
||||||
|
distribute and/or modify the software.
|
||||||
|
|
||||||
|
Also, for each author's protection and ours, we want to make certain
|
||||||
|
that everyone understands that there is no warranty for this free
|
||||||
|
software. If the software is modified by someone else and passed on, we
|
||||||
|
want its recipients to know that what they have is not the original, so
|
||||||
|
that any problems introduced by others will not reflect on the original
|
||||||
|
authors' reputations.
|
||||||
|
|
||||||
|
Finally, any free program is threatened constantly by software
|
||||||
|
patents. We wish to avoid the danger that redistributors of a free
|
||||||
|
program will individually obtain patent licenses, in effect making the
|
||||||
|
program proprietary. To prevent this, we have made it clear that any
|
||||||
|
patent must be licensed for everyone's free use or not licensed at all.
|
||||||
|
|
||||||
|
The precise terms and conditions for copying, distribution and
|
||||||
|
modification follow.
|
||||||
|
|
||||||
|
GNU GENERAL PUBLIC LICENSE
|
||||||
|
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||||
|
|
||||||
|
0. This License applies to any program or other work which contains
|
||||||
|
a notice placed by the copyright holder saying it may be distributed
|
||||||
|
under the terms of this General Public License. The "Program", below,
|
||||||
|
refers to any such program or work, and a "work based on the Program"
|
||||||
|
means either the Program or any derivative work under copyright law:
|
||||||
|
that is to say, a work containing the Program or a portion of it,
|
||||||
|
either verbatim or with modifications and/or translated into another
|
||||||
|
language. (Hereinafter, translation is included without limitation in
|
||||||
|
the term "modification".) Each licensee is addressed as "you".
|
||||||
|
|
||||||
|
Activities other than copying, distribution and modification are not
|
||||||
|
covered by this License; they are outside its scope. The act of
|
||||||
|
running the Program is not restricted, and the output from the Program
|
||||||
|
is covered only if its contents constitute a work based on the
|
||||||
|
Program (independent of having been made by running the Program).
|
||||||
|
Whether that is true depends on what the Program does.
|
||||||
|
|
||||||
|
1. You may copy and distribute verbatim copies of the Program's
|
||||||
|
source code as you receive it, in any medium, provided that you
|
||||||
|
conspicuously and appropriately publish on each copy an appropriate
|
||||||
|
copyright notice and disclaimer of warranty; keep intact all the
|
||||||
|
notices that refer to this License and to the absence of any warranty;
|
||||||
|
and give any other recipients of the Program a copy of this License
|
||||||
|
along with the Program.
|
||||||
|
|
||||||
|
You may charge a fee for the physical act of transferring a copy, and
|
||||||
|
you may at your option offer warranty protection in exchange for a fee.
|
||||||
|
|
||||||
|
2. You may modify your copy or copies of the Program or any portion
|
||||||
|
of it, thus forming a work based on the Program, and copy and
|
||||||
|
distribute such modifications or work under the terms of Section 1
|
||||||
|
above, provided that you also meet all of these conditions:
|
||||||
|
|
||||||
|
a) You must cause the modified files to carry prominent notices
|
||||||
|
stating that you changed the files and the date of any change.
|
||||||
|
|
||||||
|
b) You must cause any work that you distribute or publish, that in
|
||||||
|
whole or in part contains or is derived from the Program or any
|
||||||
|
part thereof, to be licensed as a whole at no charge to all third
|
||||||
|
parties under the terms of this License.
|
||||||
|
|
||||||
|
c) If the modified program normally reads commands interactively
|
||||||
|
when run, you must cause it, when started running for such
|
||||||
|
interactive use in the most ordinary way, to print or display an
|
||||||
|
announcement including an appropriate copyright notice and a
|
||||||
|
notice that there is no warranty (or else, saying that you provide
|
||||||
|
a warranty) and that users may redistribute the program under
|
||||||
|
these conditions, and telling the user how to view a copy of this
|
||||||
|
License. (Exception: if the Program itself is interactive but
|
||||||
|
does not normally print such an announcement, your work based on
|
||||||
|
the Program is not required to print an announcement.)
|
||||||
|
|
||||||
|
These requirements apply to the modified work as a whole. If
|
||||||
|
identifiable sections of that work are not derived from the Program,
|
||||||
|
and can be reasonably considered independent and separate works in
|
||||||
|
themselves, then this License, and its terms, do not apply to those
|
||||||
|
sections when you distribute them as separate works. But when you
|
||||||
|
distribute the same sections as part of a whole which is a work based
|
||||||
|
on the Program, the distribution of the whole must be on the terms of
|
||||||
|
this License, whose permissions for other licensees extend to the
|
||||||
|
entire whole, and thus to each and every part regardless of who wrote it.
|
||||||
|
|
||||||
|
Thus, it is not the intent of this section to claim rights or contest
|
||||||
|
your rights to work written entirely by you; rather, the intent is to
|
||||||
|
exercise the right to control the distribution of derivative or
|
||||||
|
collective works based on the Program.
|
||||||
|
|
||||||
|
In addition, mere aggregation of another work not based on the Program
|
||||||
|
with the Program (or with a work based on the Program) on a volume of
|
||||||
|
a storage or distribution medium does not bring the other work under
|
||||||
|
the scope of this License.
|
||||||
|
|
||||||
|
3. You may copy and distribute the Program (or a work based on it,
|
||||||
|
under Section 2) in object code or executable form under the terms of
|
||||||
|
Sections 1 and 2 above provided that you also do one of the following:
|
||||||
|
|
||||||
|
a) Accompany it with the complete corresponding machine-readable
|
||||||
|
source code, which must be distributed under the terms of Sections
|
||||||
|
1 and 2 above on a medium customarily used for software interchange; or,
|
||||||
|
|
||||||
|
b) Accompany it with a written offer, valid for at least three
|
||||||
|
years, to give any third party, for a charge no more than your
|
||||||
|
cost of physically performing source distribution, a complete
|
||||||
|
machine-readable copy of the corresponding source code, to be
|
||||||
|
distributed under the terms of Sections 1 and 2 above on a medium
|
||||||
|
customarily used for software interchange; or,
|
||||||
|
|
||||||
|
c) Accompany it with the information you received as to the offer
|
||||||
|
to distribute corresponding source code. (This alternative is
|
||||||
|
allowed only for noncommercial distribution and only if you
|
||||||
|
received the program in object code or executable form with such
|
||||||
|
an offer, in accord with Subsection b above.)
|
||||||
|
|
||||||
|
The source code for a work means the preferred form of the work for
|
||||||
|
making modifications to it. For an executable work, complete source
|
||||||
|
code means all the source code for all modules it contains, plus any
|
||||||
|
associated interface definition files, plus the scripts used to
|
||||||
|
control compilation and installation of the executable. However, as a
|
||||||
|
special exception, the source code distributed need not include
|
||||||
|
anything that is normally distributed (in either source or binary
|
||||||
|
form) with the major components (compiler, kernel, and so on) of the
|
||||||
|
operating system on which the executable runs, unless that component
|
||||||
|
itself accompanies the executable.
|
||||||
|
|
||||||
|
If distribution of executable or object code is made by offering
|
||||||
|
access to copy from a designated place, then offering equivalent
|
||||||
|
access to copy the source code from the same place counts as
|
||||||
|
distribution of the source code, even though third parties are not
|
||||||
|
compelled to copy the source along with the object code.
|
||||||
|
|
||||||
|
4. You may not copy, modify, sublicense, or distribute the Program
|
||||||
|
except as expressly provided under this License. Any attempt
|
||||||
|
otherwise to copy, modify, sublicense or distribute the Program is
|
||||||
|
void, and will automatically terminate your rights under this License.
|
||||||
|
However, parties who have received copies, or rights, from you under
|
||||||
|
this License will not have their licenses terminated so long as such
|
||||||
|
parties remain in full compliance.
|
||||||
|
|
||||||
|
5. You are not required to accept this License, since you have not
|
||||||
|
signed it. However, nothing else grants you permission to modify or
|
||||||
|
distribute the Program or its derivative works. These actions are
|
||||||
|
prohibited by law if you do not accept this License. Therefore, by
|
||||||
|
modifying or distributing the Program (or any work based on the
|
||||||
|
Program), you indicate your acceptance of this License to do so, and
|
||||||
|
all its terms and conditions for copying, distributing or modifying
|
||||||
|
the Program or works based on it.
|
||||||
|
|
||||||
|
6. Each time you redistribute the Program (or any work based on the
|
||||||
|
Program), the recipient automatically receives a license from the
|
||||||
|
original licensor to copy, distribute or modify the Program subject to
|
||||||
|
these terms and conditions. You may not impose any further
|
||||||
|
restrictions on the recipients' exercise of the rights granted herein.
|
||||||
|
You are not responsible for enforcing compliance by third parties to
|
||||||
|
this License.
|
||||||
|
|
||||||
|
7. If, as a consequence of a court judgment or allegation of patent
|
||||||
|
infringement or for any other reason (not limited to patent issues),
|
||||||
|
conditions are imposed on you (whether by court order, agreement or
|
||||||
|
otherwise) that contradict the conditions of this License, they do not
|
||||||
|
excuse you from the conditions of this License. If you cannot
|
||||||
|
distribute so as to satisfy simultaneously your obligations under this
|
||||||
|
License and any other pertinent obligations, then as a consequence you
|
||||||
|
may not distribute the Program at all. For example, if a patent
|
||||||
|
license would not permit royalty-free redistribution of the Program by
|
||||||
|
all those who receive copies directly or indirectly through you, then
|
||||||
|
the only way you could satisfy both it and this License would be to
|
||||||
|
refrain entirely from distribution of the Program.
|
||||||
|
|
||||||
|
If any portion of this section is held invalid or unenforceable under
|
||||||
|
any particular circumstance, the balance of the section is intended to
|
||||||
|
apply and the section as a whole is intended to apply in other
|
||||||
|
circumstances.
|
||||||
|
|
||||||
|
It is not the purpose of this section to induce you to infringe any
|
||||||
|
patents or other property right claims or to contest validity of any
|
||||||
|
such claims; this section has the sole purpose of protecting the
|
||||||
|
integrity of the free software distribution system, which is
|
||||||
|
implemented by public license practices. Many people have made
|
||||||
|
generous contributions to the wide range of software distributed
|
||||||
|
through that system in reliance on consistent application of that
|
||||||
|
system; it is up to the author/donor to decide if he or she is willing
|
||||||
|
to distribute software through any other system and a licensee cannot
|
||||||
|
impose that choice.
|
||||||
|
|
||||||
|
This section is intended to make thoroughly clear what is believed to
|
||||||
|
be a consequence of the rest of this License.
|
||||||
|
|
||||||
|
8. If the distribution and/or use of the Program is restricted in
|
||||||
|
certain countries either by patents or by copyrighted interfaces, the
|
||||||
|
original copyright holder who places the Program under this License
|
||||||
|
may add an explicit geographical distribution limitation excluding
|
||||||
|
those countries, so that distribution is permitted only in or among
|
||||||
|
countries not thus excluded. In such case, this License incorporates
|
||||||
|
the limitation as if written in the body of this License.
|
||||||
|
|
||||||
|
9. The Free Software Foundation may publish revised and/or new versions
|
||||||
|
of the General Public License from time to time. Such new versions will
|
||||||
|
be similar in spirit to the present version, but may differ in detail to
|
||||||
|
address new problems or concerns.
|
||||||
|
|
||||||
|
Each version is given a distinguishing version number. If the Program
|
||||||
|
specifies a version number of this License which applies to it and "any
|
||||||
|
later version", you have the option of following the terms and conditions
|
||||||
|
either of that version or of any later version published by the Free
|
||||||
|
Software Foundation. If the Program does not specify a version number of
|
||||||
|
this License, you may choose any version ever published by the Free Software
|
||||||
|
Foundation.
|
||||||
|
|
||||||
|
10. If you wish to incorporate parts of the Program into other free
|
||||||
|
programs whose distribution conditions are different, write to the author
|
||||||
|
to ask for permission. For software which is copyrighted by the Free
|
||||||
|
Software Foundation, write to the Free Software Foundation; we sometimes
|
||||||
|
make exceptions for this. Our decision will be guided by the two goals
|
||||||
|
of preserving the free status of all derivatives of our free software and
|
||||||
|
of promoting the sharing and reuse of software generally.
|
||||||
|
|
||||||
|
NO WARRANTY
|
||||||
|
|
||||||
|
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
|
||||||
|
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
|
||||||
|
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
|
||||||
|
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
|
||||||
|
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||||
|
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
|
||||||
|
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
|
||||||
|
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
|
||||||
|
REPAIR OR CORRECTION.
|
||||||
|
|
||||||
|
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||||
|
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
|
||||||
|
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
|
||||||
|
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
|
||||||
|
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
|
||||||
|
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
|
||||||
|
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
|
||||||
|
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
|
||||||
|
POSSIBILITY OF SUCH DAMAGES.
|
||||||
|
|
||||||
|
END OF TERMS AND CONDITIONS
|
||||||
|
|
||||||
|
How to Apply These Terms to Your New Programs
|
||||||
|
|
||||||
|
If you develop a new program, and you want it to be of the greatest
|
||||||
|
possible use to the public, the best way to achieve this is to make it
|
||||||
|
free software which everyone can redistribute and change under these terms.
|
||||||
|
|
||||||
|
To do so, attach the following notices to the program. It is safest
|
||||||
|
to attach them to the start of each source file to most effectively
|
||||||
|
convey the exclusion of warranty; and each file should have at least
|
||||||
|
the "copyright" line and a pointer to where the full notice is found.
|
||||||
|
|
||||||
|
<one line to give the program's name and a brief idea of what it does.>
|
||||||
|
Copyright (C) <year> <name of author>
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation; either version 2 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License along
|
||||||
|
with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
|
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
|
||||||
|
Also add information on how to contact you by electronic and paper mail.
|
||||||
|
|
||||||
|
If the program is interactive, make it output a short notice like this
|
||||||
|
when it starts in an interactive mode:
|
||||||
|
|
||||||
|
Gnomovision version 69, Copyright (C) year name of author
|
||||||
|
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||||
|
This is free software, and you are welcome to redistribute it
|
||||||
|
under certain conditions; type `show c' for details.
|
||||||
|
|
||||||
|
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||||
|
parts of the General Public License. Of course, the commands you use may
|
||||||
|
be called something other than `show w' and `show c'; they could even be
|
||||||
|
mouse-clicks or menu items--whatever suits your program.
|
||||||
|
|
||||||
|
You should also get your employer (if you work as a programmer) or your
|
||||||
|
school, if any, to sign a "copyright disclaimer" for the program, if
|
||||||
|
necessary. Here is a sample; alter the names:
|
||||||
|
|
||||||
|
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
|
||||||
|
`Gnomovision' (which makes passes at compilers) written by James Hacker.
|
||||||
|
|
||||||
|
<signature of Ty Coon>, 1 April 1989
|
||||||
|
Ty Coon, President of Vice
|
||||||
|
|
||||||
|
This General Public License does not permit incorporating your program into
|
||||||
|
proprietary programs. If your program is a subroutine library, you may
|
||||||
|
consider it more useful to permit linking proprietary applications with the
|
||||||
|
library. If this is what you want to do, use the GNU Lesser General
|
||||||
|
Public License instead of this License.
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
Url to Video Filter
|
||||||
|
|
||||||
|
### Supported Services ###
|
||||||
|
|
||||||
|
Currently this module supports the following services:
|
||||||
|
|
||||||
|
* YouTube
|
||||||
|
* Vimeo
|
||||||
|
|
||||||
|
If you have another service you would like added, please open a feature request in the support queue.
|
||||||
|
|
||||||
|
|
||||||
|
### Configuration ###
|
||||||
|
|
||||||
|
* Install the module as you would any module
|
||||||
|
* Edit or create a new text format at /config/content/formats
|
||||||
|
* Check the Convert URLs to embedded videos checkbox
|
||||||
|
* Select the video sharing services you wish to enable in the settings form
|
||||||
|
* If you have enabled the 'Convert URLs into links' filter, ensure that this filter comes before it
|
||||||
@@ -0,0 +1,54 @@
|
|||||||
|
.url-to-video-container {
|
||||||
|
display: block;
|
||||||
|
margin: 20px auto;
|
||||||
|
width: 100%; }
|
||||||
|
.url-to-video-container.no-js {
|
||||||
|
border: solid black 1px; }
|
||||||
|
.url-to-video-container.no-js .loader {
|
||||||
|
background: url(../images/no-js.png) no-repeat center center;
|
||||||
|
background-size: 40px 40px; }
|
||||||
|
.url-to-video-container.no-js .url-to-video-player {
|
||||||
|
cursor: auto; }
|
||||||
|
.url-to-video-container .loader {
|
||||||
|
top: 240px;
|
||||||
|
left: 50%;
|
||||||
|
transform: translate(-50%, -50%);
|
||||||
|
background: #FFF url(../images/ajax-loader.gif) no-repeat center center; }
|
||||||
|
.url-to-video-container .url-to-video-player {
|
||||||
|
display: block;
|
||||||
|
width: 100%;
|
||||||
|
/* assuming that the video has a 16:9 ratio */
|
||||||
|
padding-bottom: 56.25%;
|
||||||
|
overflow: hidden;
|
||||||
|
position: relative;
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
cursor: hand;
|
||||||
|
cursor: pointer;
|
||||||
|
display: block; }
|
||||||
|
.url-to-video-container .url-to-video-player .player-thumb {
|
||||||
|
background-position: center center;
|
||||||
|
background-size: cover;
|
||||||
|
position: absolute;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
cursor: pointer; }
|
||||||
|
.url-to-video-container .url-to-video-player .play-button {
|
||||||
|
height: 40px;
|
||||||
|
width: 40px;
|
||||||
|
display: block;
|
||||||
|
background: url(../images/play-button.png) no-repeat center center;
|
||||||
|
background-size: 40px 40px;
|
||||||
|
position: absolute;
|
||||||
|
top: 240px;
|
||||||
|
left: 50%;
|
||||||
|
transform: translate(-50%, -50%);
|
||||||
|
cursor: pointer; }
|
||||||
|
.url-to-video-container .player-iframe {
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
position: absolute;
|
||||||
|
top: 0;
|
||||||
|
left: 0; }
|
||||||
@@ -0,0 +1,72 @@
|
|||||||
|
.url-to-video-container
|
||||||
|
{
|
||||||
|
display:block;
|
||||||
|
margin:20px auto;
|
||||||
|
width:100%;
|
||||||
|
&.no-js
|
||||||
|
{
|
||||||
|
border:solid black 1px;
|
||||||
|
.loader
|
||||||
|
{
|
||||||
|
background:url(../images/no-js.png) no-repeat center center;
|
||||||
|
background-size:40px 40px;
|
||||||
|
}
|
||||||
|
.url-to-video-player
|
||||||
|
{
|
||||||
|
cursor:auto;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.loader
|
||||||
|
{
|
||||||
|
top:240px;
|
||||||
|
left:50%;
|
||||||
|
transform:translate(-50%, -50%);
|
||||||
|
background:#FFF url(../images/ajax-loader.gif) no-repeat center center;
|
||||||
|
}
|
||||||
|
.url-to-video-player
|
||||||
|
{
|
||||||
|
display:block;
|
||||||
|
width:100%;
|
||||||
|
/* assuming that the video has a 16:9 ratio */
|
||||||
|
padding-bottom:56.25%;
|
||||||
|
overflow:hidden;
|
||||||
|
position:relative;
|
||||||
|
width:100%;
|
||||||
|
height:100%;
|
||||||
|
cursor:hand;
|
||||||
|
cursor:pointer;
|
||||||
|
display: block;
|
||||||
|
.player-thumb
|
||||||
|
{
|
||||||
|
background-position:center center;
|
||||||
|
background-size:cover;
|
||||||
|
position: absolute;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
cursor:pointer;
|
||||||
|
}
|
||||||
|
.play-button
|
||||||
|
{
|
||||||
|
height:40px;
|
||||||
|
width:40px;
|
||||||
|
display:block;
|
||||||
|
background:url(../images/play-button.png) no-repeat center center;
|
||||||
|
background-size:40px 40px;
|
||||||
|
position:absolute;
|
||||||
|
top:240px;
|
||||||
|
left:50%;
|
||||||
|
transform:translate(-50%, -50%);
|
||||||
|
cursor:pointer;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.player-iframe
|
||||||
|
{
|
||||||
|
width:100%;
|
||||||
|
height:100%;
|
||||||
|
position:absolute;
|
||||||
|
top:0;
|
||||||
|
left:0;
|
||||||
|
}
|
||||||
|
}
|
||||||
Binary file not shown.
|
After Width: | Height: | Size: 8.6 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 2.5 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 2.4 KiB |
@@ -0,0 +1,66 @@
|
|||||||
|
/*global jQuery, Drupal, drupalSettings*/
|
||||||
|
/*jslint white:true, multivar, this, browser:true*/
|
||||||
|
|
||||||
|
(function($, Drupal, drupalSettings)
|
||||||
|
{
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
function vimeoVideoEnable(context)
|
||||||
|
{
|
||||||
|
$(context).find(".vimeo-player").once("vimeo-video-enable").each(function()
|
||||||
|
{
|
||||||
|
var vimeoID = $(this).attr("data-vimeo-id");
|
||||||
|
|
||||||
|
$(this).parent().removeClass("no-js");
|
||||||
|
|
||||||
|
if(drupalSettings.urlToVideoFilter.autoload)
|
||||||
|
{
|
||||||
|
$(this).empty().append($("<iframe/>").attr("src", "//player.vimeo.com/video/" + vimeoID + "?autopause=1&autoplay=0&badge=1&byline=1&loop=0&portrait=1&autopause=1&fullscreen=1").attr("frameborder", "0").attr("class", "player-iframe vimeo-iframe"));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$.ajax(
|
||||||
|
{
|
||||||
|
url:"//vimeo.com/api/v2/video/" + vimeoID + ".json",
|
||||||
|
context:$(this),
|
||||||
|
success:function(data)
|
||||||
|
{
|
||||||
|
if(data[0] && data[0].thumbnail_large)
|
||||||
|
{
|
||||||
|
$(this).empty().append($("<span/>").append($("<img/>", {class:"player-thumb", src:data[0].thumbnail_large})).append($("<span/>", {class:"play-button"})).click(function(e)
|
||||||
|
{
|
||||||
|
e.stopPropagation();
|
||||||
|
|
||||||
|
Drupal.detachBehaviors($(this).parent().parent());
|
||||||
|
|
||||||
|
$(this).replaceWith($("<iframe/>").attr("src", "//player.vimeo.com/video/" + vimeoID + "?autopause=1&autoplay=1&badge=1&byline=1&loop=0&portrait=1&autopause=1&fullscreen=1").attr("frameborder", "0").attr("class", "player-iframe vimeo-iframe"));
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$(this).empty().append($("<span/>").append($("<span/>", {class:"play-button"})).click(function(e)
|
||||||
|
{
|
||||||
|
e.stopPropagation();
|
||||||
|
|
||||||
|
Drupal.detachBehaviors($(this).parent().parent());
|
||||||
|
|
||||||
|
$(this).replaceWith($("<iframe/>").attr("src", "//player.vimeo.com/video/" + vimeoID + "?autopause=1&autoplay=1&badge=1&byline=1&loop=0&portrait=1&autopause=1&fullscreen=1").attr("frameborder", "0").attr("class", "player-iframe vimeo-iframe"));
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
Drupal.behaviors.urlToVideoFilterVimeo = {
|
||||||
|
attach:function(context)
|
||||||
|
{
|
||||||
|
vimeoVideoEnable(context);
|
||||||
|
},
|
||||||
|
detach:function(context)
|
||||||
|
{
|
||||||
|
$(".vimeo-player", context).unbind("click");
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}(jQuery, Drupal, drupalSettings));
|
||||||
@@ -0,0 +1,55 @@
|
|||||||
|
/*global jQuery, Drupal, drupalSettings*/
|
||||||
|
/*jslint white:true, multivar, this, browser:true*/
|
||||||
|
|
||||||
|
(function($, Drupal, drupalSettings)
|
||||||
|
{
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
function youtubeVideoEnable(context)
|
||||||
|
{
|
||||||
|
$(context).find(".youtube-player").once("youtube-video-enable").each(function()
|
||||||
|
{
|
||||||
|
var youtubeID, youtubePreview;
|
||||||
|
|
||||||
|
youtubeID = $(this).attr("data-youtube-id");
|
||||||
|
|
||||||
|
$(this).parent().removeClass("no-js");
|
||||||
|
|
||||||
|
if(drupalSettings.urlToVideoFilter.autoload)
|
||||||
|
{
|
||||||
|
$(this).empty().append($("<iframe/>").attr("src", "//www.youtube.com/embed/" + youtubeID + "?autoplay=0&autohide=2&border=0&wmode=opaque&enablejsapi=1").attr("frameborder", "0").attr("class", "player-iframe youtube-iframe"));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if(drupalSettings.urlToVideoFilter.youtubeWebp)
|
||||||
|
{
|
||||||
|
youtubePreview = "//i.ytimg.com/vi_webp/" + youtubeID + "/sddefault.webp";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
youtubePreview = "//i.ytimg.com/vi/" + youtubeID + "/hqdefault.jpg";
|
||||||
|
}
|
||||||
|
|
||||||
|
$(this).empty().append($("<span/>").append($("<div/>", {class:"player-thumb",style:"background-image:url(" + youtubePreview + ")"})).append($("<span/>", {class:"play-button"})).click(function(e)
|
||||||
|
{
|
||||||
|
e.stopPropagation();
|
||||||
|
|
||||||
|
Drupal.detachBehaviors($(this).parent().parent());
|
||||||
|
|
||||||
|
$(this).replaceWith($("<iframe/>").attr("src", "//www.youtube.com/embed/" + youtubeID + "?autoplay=1&autohide=2&border=0&wmode=opaque&enablejsapi=1").attr("frameborder", "0").attr("class", "player-iframe youtube-iframe"));
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
Drupal.behaviors.urlToVideoFilterYoutube = {
|
||||||
|
attach:function(context)
|
||||||
|
{
|
||||||
|
youtubeVideoEnable(context);
|
||||||
|
},
|
||||||
|
detach:function(context)
|
||||||
|
{
|
||||||
|
$(".youtube-player", context).unbind("click");
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}(jQuery, Drupal, drupalSettings));
|
||||||
+159
@@ -0,0 +1,159 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Drupal\url_to_video_filter\Plugin\Filter;
|
||||||
|
|
||||||
|
use Drupal\Core\Form\FormStateInterface;
|
||||||
|
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
|
||||||
|
use Drupal\filter\Plugin\FilterBase;
|
||||||
|
use Drupal\filter\FilterProcessResult;
|
||||||
|
use Drupal\url_to_video_filter\Service\UrlToVideoFilterServiceInterface;
|
||||||
|
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provides a filter to convert various video sharing website URLs to links.
|
||||||
|
*
|
||||||
|
* @Filter(
|
||||||
|
* id = "filter_url_to_video",
|
||||||
|
* title = @Translation("Convert URLs to embedded videos"),
|
||||||
|
* description = @Translation("Converts URLs for various video sites and converts them to embedded videos"),
|
||||||
|
* type = Drupal\filter\Plugin\FilterInterface::TYPE_MARKUP_LANGUAGE,
|
||||||
|
* settings = {
|
||||||
|
* "youtube" = true,
|
||||||
|
* "youtube_webp_preview" = false,
|
||||||
|
* "autoload" = false,
|
||||||
|
* "vimeo" = true,
|
||||||
|
* }
|
||||||
|
* )
|
||||||
|
*/
|
||||||
|
class FilterUrlToVideo extends FilterBase implements ContainerFactoryPluginInterface
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The Url to Video Filter Service
|
||||||
|
*
|
||||||
|
* @var \Drupal\url_to_video_filter\Service\UrlToVideoFilterServiceInterface
|
||||||
|
*/
|
||||||
|
protected $urlToVideoFilterService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructs a UrlToVideoFilter object
|
||||||
|
*
|
||||||
|
* @param array $configuration
|
||||||
|
* @param string $plugin_id
|
||||||
|
* @param mixed $plugin_definition
|
||||||
|
* @param \Drupal\url_to_video_filter\Service\UrlToVideoFilterServiceInterface $urlToVideoFilterService
|
||||||
|
* The Url to Video Filter Service
|
||||||
|
*/
|
||||||
|
public function __construct(array $configuration, $plugin_id, $plugin_definition, UrlToVideoFilterServiceInterface $urlToVideoFilterService)
|
||||||
|
{
|
||||||
|
parent::__construct($configuration, $plugin_id, $plugin_definition);
|
||||||
|
|
||||||
|
$this->urlToVideoFilterService = $urlToVideoFilterService;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
static public function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition)
|
||||||
|
{
|
||||||
|
return new static(
|
||||||
|
$configuration,
|
||||||
|
$plugin_id,
|
||||||
|
$plugin_definition,
|
||||||
|
$container->get('url_to_video_filter.service')
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function process($text, $langcode)
|
||||||
|
{
|
||||||
|
$youtube_found = FALSE;
|
||||||
|
$vimeo_found = FALSE;
|
||||||
|
|
||||||
|
// Process YouTube URLs
|
||||||
|
if($this->settings['youtube'])
|
||||||
|
{
|
||||||
|
$filter = $this->urlToVideoFilterService->convertYouTubeUrls($text);
|
||||||
|
$text = $filter['text'];
|
||||||
|
$youtube_found = $filter['url_found'];
|
||||||
|
}
|
||||||
|
|
||||||
|
// Process Vimeo Urls
|
||||||
|
if($this->settings['vimeo'])
|
||||||
|
{
|
||||||
|
$filter = $this->urlToVideoFilterService->convertVimeoUrls($text);
|
||||||
|
$text = $filter['text'];
|
||||||
|
$vimeo_found = $filter['url_found'];
|
||||||
|
}
|
||||||
|
|
||||||
|
$libraries = [];
|
||||||
|
$result = new FilterProcessResult($text);
|
||||||
|
if($youtube_found)
|
||||||
|
{
|
||||||
|
$libraries[] = 'url_to_video_filter/youtube_embed';
|
||||||
|
}
|
||||||
|
|
||||||
|
if($vimeo_found)
|
||||||
|
{
|
||||||
|
$libraries[] = 'url_to_video_filter/vimeo_embed';
|
||||||
|
}
|
||||||
|
|
||||||
|
$js_settings['urlToVideoFilter'] = [];
|
||||||
|
|
||||||
|
if($this->settings['youtube'] && $this->settings['youtube_webp_preview'])
|
||||||
|
{
|
||||||
|
$js_settings['urlToVideoFilter']['youtubeWebp'] = TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if($this->settings['autoload'])
|
||||||
|
{
|
||||||
|
$js_settings['urlToVideoFilter']['autoload'] = TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
$result->setAttachments([
|
||||||
|
'drupalSettings' => $js_settings,
|
||||||
|
'library' => $libraries,
|
||||||
|
]);
|
||||||
|
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function settingsForm(array $form, FormStateInterface $form_state)
|
||||||
|
{
|
||||||
|
// Enable filtering for YouTube URLs
|
||||||
|
$form['youtube'] = [
|
||||||
|
'#type' => 'checkbox',
|
||||||
|
'#title' => $this->t('Filter for YouTube URLs'),
|
||||||
|
'#default_value' => $this->settings['youtube'],
|
||||||
|
];
|
||||||
|
|
||||||
|
$form['youtube_webp_preview'] = [
|
||||||
|
'#type' => 'checkbox',
|
||||||
|
'#title' => $this->t('Use webp image for YouTube preview'),
|
||||||
|
'#description'=> $this->t('Warning - not compatible with some browsers'),
|
||||||
|
'#default_value' => $this->settings['youtube_webp_preview'],
|
||||||
|
'#states' => [
|
||||||
|
'visible' => [
|
||||||
|
'#edit-filters-filter-url-to-video-settings-youtube' => ['checked' => TRUE],
|
||||||
|
'#edit-filters-filter-url-to-video-settings-autoload' => ['checked' => FALSE],
|
||||||
|
],
|
||||||
|
],
|
||||||
|
];
|
||||||
|
|
||||||
|
// Enable filtering for Vimeo URLs
|
||||||
|
$form['vimeo'] = [
|
||||||
|
'#type' => 'checkbox',
|
||||||
|
'#title' => $this->t('Filter for Vimeo URLs'),
|
||||||
|
'#default_value' => $this->settings['vimeo'],
|
||||||
|
];
|
||||||
|
|
||||||
|
$form['autoload'] = [
|
||||||
|
'#type' => 'checkbox',
|
||||||
|
'#title' => $this->t('Autoload players when page has loaded.'),
|
||||||
|
'#default_value' => $this->settings['autoload'],
|
||||||
|
];
|
||||||
|
|
||||||
|
return $form;
|
||||||
|
}
|
||||||
|
}
|
||||||
+149
@@ -0,0 +1,149 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Drupal\url_to_video_filter\Service;
|
||||||
|
|
||||||
|
use Drupal\url_to_video_filter\Service\UrlToVideoFilterServiceInterface;
|
||||||
|
|
||||||
|
class UrlToVideoFilterService implements UrlToVideoFilterServiceInterface
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function convertYouTubeUrls($text)
|
||||||
|
{
|
||||||
|
$return = [
|
||||||
|
'text' => $text,
|
||||||
|
'url_found' => FALSE,
|
||||||
|
];
|
||||||
|
|
||||||
|
$urls = $this->parseYouTubeUrls($text);
|
||||||
|
if(count($urls))
|
||||||
|
{
|
||||||
|
$return['url_found'] = TRUE;
|
||||||
|
foreach($urls as $url)
|
||||||
|
{
|
||||||
|
$embed_code = $this->convertYouTubeUrlToEmbedCode($url);
|
||||||
|
$return['text'] = str_replace($url, $embed_code, $return['text']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function convertVimeoUrls($text)
|
||||||
|
{
|
||||||
|
$return = [
|
||||||
|
'text' => $text,
|
||||||
|
'url_found' => FALSE,
|
||||||
|
];
|
||||||
|
|
||||||
|
$urls = $this->parseVimeoUrls($text);
|
||||||
|
if(count($urls))
|
||||||
|
{
|
||||||
|
$return['url_found'] = TRUE;
|
||||||
|
foreach($urls as $url)
|
||||||
|
{
|
||||||
|
$embed_code = $this->convertVimeoUrlToEmbedCode($url);
|
||||||
|
$return['text'] = str_replace($url, $embed_code, $return['text']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Parses text for YouTube URLs
|
||||||
|
*
|
||||||
|
* @param $text
|
||||||
|
* The text to parse for YouTube URLs.
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
* An array containing any YouTube URLs found in the text
|
||||||
|
*/
|
||||||
|
protected function parseYouTubeUrls($text)
|
||||||
|
{
|
||||||
|
$urls = array();
|
||||||
|
|
||||||
|
$youtube_regex = '/(^|\b)http(s)?:\/\/(www\.)?youtube\.com\/watch.+?(?=($|\s|\r|\r\n|\n|<))/m';
|
||||||
|
preg_match_all($youtube_regex, $text, $matches);
|
||||||
|
$urls = array_merge($urls, $matches[0]);
|
||||||
|
|
||||||
|
$youtube_regex = '/(^|\b)http(s)?:\/\/(www\.)?youtu\.be\/.+?(?=($|\s|\r|\r\n|\n|<))/m';
|
||||||
|
preg_match_all($youtube_regex, $text, $matches);
|
||||||
|
$urls = array_merge($urls, $matches[0]);
|
||||||
|
|
||||||
|
return $urls;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert YouTube URL to YouTube embed text
|
||||||
|
*
|
||||||
|
* @param string $url
|
||||||
|
* The YouTube URL to convert
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
* HTML containing the embed code for the YouTube video
|
||||||
|
* for the given URL.
|
||||||
|
*/
|
||||||
|
protected function convertYouTubeUrlToEmbedCode($url)
|
||||||
|
{
|
||||||
|
$embed_code = '';
|
||||||
|
|
||||||
|
if(strpos($url, 'youtube.com'))
|
||||||
|
{
|
||||||
|
$video_key = preg_replace('/(http)?(s)?(:\/\/)?(www\.)?youtube\.com\/watch\?v=/', '', $url);
|
||||||
|
}
|
||||||
|
elseif(strpos($url, 'youtu.be'))
|
||||||
|
{
|
||||||
|
$video_key = preg_replace('/(http)?(s)?(:\/\/)?(www\.)?youtu.be\//', '', $url);
|
||||||
|
}
|
||||||
|
|
||||||
|
$embed_code .= '<span class="url-to-video-container youtube-container no-js">';
|
||||||
|
$embed_code .= '<span class="youtube-player url-to-video-player loader" data-youtube-id="'. $video_key . '"></span>';
|
||||||
|
$embed_code .= '</span>';
|
||||||
|
|
||||||
|
return $embed_code;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Parses text for Vimeo URLs
|
||||||
|
*
|
||||||
|
* @param $text
|
||||||
|
* The text to parse for Vimeo URLs.
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
* An array containing any Vimeo URLs found in the text
|
||||||
|
*/
|
||||||
|
protected function parseVimeoUrls($text)
|
||||||
|
{
|
||||||
|
$vimeo_regex = '/(^|\b)http(s)?:\/\/(www\.)?vimeo\.com.+?(?=($|\s|\r|\r\n|\n|<))/m';
|
||||||
|
preg_match_all($vimeo_regex, $text, $matches);
|
||||||
|
|
||||||
|
return $matches[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert Vimeo URL to YouTube embed text
|
||||||
|
*
|
||||||
|
* @param string $url
|
||||||
|
* The Vimeo URL to convert
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
* HTML containing the embed code for the Vimeo video
|
||||||
|
* for the given URL.
|
||||||
|
*/
|
||||||
|
protected function convertVimeoUrlToEmbedCode($url)
|
||||||
|
{
|
||||||
|
$embed_code = '';
|
||||||
|
|
||||||
|
$video_key = preg_replace('/(http)?(s)?(:\/\/)?(www\.)?vimeo\.com\//', '', $url);
|
||||||
|
$embed_code .= '<span class="url-to-video-container vimeo-container no-js">';
|
||||||
|
$embed_code .= '<span class="vimeo-player url-to-video-player loader" data-vimeo-id="'. $video_key . '"></span>';
|
||||||
|
$embed_code .= '</span>';
|
||||||
|
|
||||||
|
return $embed_code;
|
||||||
|
}
|
||||||
|
}
|
||||||
+34
@@ -0,0 +1,34 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Drupal\url_to_video_filter\Service;
|
||||||
|
|
||||||
|
interface UrlToVideoFilterServiceInterface
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Converts URLs to embedded YouTube videos
|
||||||
|
*
|
||||||
|
* @param string $text
|
||||||
|
* The text to be parsed for YouTube URLs
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
* An array containing the following keys:
|
||||||
|
* - text: The text with the URLs replaced by the YouTube embed code
|
||||||
|
* - url_found: A boolean indicating whether any URLs were found in
|
||||||
|
* the given text.
|
||||||
|
*/
|
||||||
|
public function convertYouTubeUrls($text);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Converts URLs to embedded Vimeo videos
|
||||||
|
*
|
||||||
|
* @param string $text
|
||||||
|
* The text to be parsed for Vimeo URLs
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
* An array containing the following keys:
|
||||||
|
* - text: The text with the URLs replaced by the YouTube embed code
|
||||||
|
* - url_found: A boolean indicating whether any URLs were found in
|
||||||
|
* the given text.
|
||||||
|
*/
|
||||||
|
public function convertVimeoUrls($text);
|
||||||
|
}
|
||||||
+189
@@ -0,0 +1,189 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Drupal\Tests\url_to_video_filter\FunctionalJavascript;
|
||||||
|
|
||||||
|
use Drupal\Tests\url_to_video_filter\FunctionalJavascript\UrlToVideoFilterFunctionalJavascriptTestBase;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @group url_to_video_filter
|
||||||
|
*/
|
||||||
|
class UrlToVideoFilterFunctionalJavascriptTest extends UrlToVideoFilterFunctionalJavascriptTestBase
|
||||||
|
{
|
||||||
|
public static $modules = ['url_to_video_filter', 'filter', 'node'];
|
||||||
|
|
||||||
|
protected $filter_type = 'video_filter';
|
||||||
|
|
||||||
|
protected $youtube_url = 'www.youtube.com/watch?v=';
|
||||||
|
protected $youtu_be_url = 'www.youtu.be/';
|
||||||
|
protected $vimeo_url = 'vimeo.com/';
|
||||||
|
|
||||||
|
protected $youtube_id = '3qrNRzkwlbU';
|
||||||
|
protected $vimeo_id = '195421709';
|
||||||
|
|
||||||
|
public function setUp()
|
||||||
|
{
|
||||||
|
parent::setUp();
|
||||||
|
|
||||||
|
$admin_role = $this->createAdminRole();
|
||||||
|
$this->createContentType(['type' => 'article']);
|
||||||
|
$adminUser = $this->createUser(['administer site configuration', 'administer filters', 'administer themes']);
|
||||||
|
$adminUser->addRole($admin_role);
|
||||||
|
$this->drupalLogin($adminUser);
|
||||||
|
$this->drupalGet('/admin/appearance');
|
||||||
|
$this->assertStatusCodeEquals(200);
|
||||||
|
$this->clickByXpath('//a[@title="Install Bartik as default theme"]');
|
||||||
|
$this->assertStatusCodeEquals(200);
|
||||||
|
$this->drupalGet('/admin/config/content/formats/add');
|
||||||
|
$this->assertStatusCodeEquals(200);
|
||||||
|
$this->fillTextValue('#edit-name', 'Video Filter');
|
||||||
|
$this->checkCheckbox("#edit-roles-authenticated");
|
||||||
|
$this->checkCheckbox('#edit-filters-filter-url-to-video-status');
|
||||||
|
$this->getSession()->evaluateScript('jQuery(".form-type-machine-name.visually-hidden").removeClass("visually-hidden");');
|
||||||
|
$this->fillTextValue('#edit-format', $this->filter_type);
|
||||||
|
$this->click('#edit-actions-submit');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testYouTubeEmbed()
|
||||||
|
{
|
||||||
|
$this->setFilterSettings(TRUE, TRUE);
|
||||||
|
|
||||||
|
$node = $this->createArticle('https://' . $this->youtube_url . $this->youtube_id . ' some text', $this->filter_type);
|
||||||
|
$this->drupalGet('/node/' . $node->id());
|
||||||
|
$this->assertStatusCodeEquals(200);
|
||||||
|
$this->assertElementExistsXpath('//span[@class="url-to-video-container youtube-container no-js"]/span[@data-youtube-id="' . $this->youtube_id . '"]');
|
||||||
|
|
||||||
|
$node = $this->createArticle('http://' . $this->youtube_url . $this->youtube_id . ' some text', $this->filter_type);
|
||||||
|
$this->drupalGet('/node/' . $node->id());
|
||||||
|
$this->assertStatusCodeEquals(200);
|
||||||
|
$this->assertElementExistsXpath('//span[@class="url-to-video-container youtube-container no-js"]/span[@data-youtube-id="' . $this->youtube_id . '"]');
|
||||||
|
|
||||||
|
$node = $this->createArticle('some text https://' . $this->youtube_url . $this->youtube_id, $this->filter_type);
|
||||||
|
$this->drupalGet('/node/' . $node->id());
|
||||||
|
$this->assertStatusCodeEquals(200);
|
||||||
|
$this->assertElementExistsXpath('//span[@class="url-to-video-container youtube-container no-js"]/span[@data-youtube-id="' . $this->youtube_id . '"]');
|
||||||
|
|
||||||
|
$node = $this->createArticle('some text http://' . $this->youtube_url . $this->youtube_id, $this->filter_type);
|
||||||
|
$this->drupalGet('/node/' . $node->id());
|
||||||
|
$this->assertStatusCodeEquals(200);
|
||||||
|
$this->assertElementExistsXpath('//span[@class="url-to-video-container youtube-container no-js"]/span[@data-youtube-id="' . $this->youtube_id . '"]');
|
||||||
|
|
||||||
|
$node = $this->createArticle('https://' . $this->youtu_be_url . $this->youtube_id . ' some text', $this->filter_type);
|
||||||
|
$this->drupalGet('/node/' . $node->id());
|
||||||
|
$this->assertStatusCodeEquals(200);
|
||||||
|
$this->assertElementExistsXpath('//span[@class="url-to-video-container youtube-container no-js"]/span[@data-youtube-id="' . $this->youtube_id . '"]');
|
||||||
|
|
||||||
|
$node = $this->createArticle('http://' . $this->youtu_be_url . $this->youtube_id . ' some text', $this->filter_type);
|
||||||
|
$this->drupalGet('/node/' . $node->id());
|
||||||
|
$this->assertStatusCodeEquals(200);
|
||||||
|
$this->assertElementExistsXpath('//span[@class="url-to-video-container youtube-container no-js"]/span[@data-youtube-id="' . $this->youtube_id . '"]');
|
||||||
|
|
||||||
|
$node = $this->createArticle('some text https://' . $this->youtu_be_url . $this->youtube_id, $this->filter_type);
|
||||||
|
$this->drupalGet('/node/' . $node->id());
|
||||||
|
$this->assertStatusCodeEquals(200);
|
||||||
|
$this->assertElementExistsXpath('//span[@class="url-to-video-container youtube-container no-js"]/span[@data-youtube-id="' . $this->youtube_id . '"]');
|
||||||
|
|
||||||
|
$node = $this->createArticle('some text http://' . $this->youtu_be_url . $this->youtube_id, $this->filter_type);
|
||||||
|
$this->drupalGet('/node/' . $node->id());
|
||||||
|
$this->assertStatusCodeEquals(200);
|
||||||
|
$this->assertElementExistsXpath('//span[@class="url-to-video-container youtube-container no-js"]/span[@data-youtube-id="' . $this->youtube_id . '"]');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testYouTubeNotEmbed()
|
||||||
|
{
|
||||||
|
$this->setFilterSettings(FALSE, TRUE);
|
||||||
|
|
||||||
|
$node = $this->createArticle('https://' . $this->youtube_url . $this->youtube_id . ' some text', $this->filter_type);
|
||||||
|
$this->drupalGet('/node/' . $node->id());
|
||||||
|
$this->assertStatusCodeEquals(200);
|
||||||
|
$this->assertElementNotExistsXpath('//span[@class="url-to-video-container youtube-container no-js"]');
|
||||||
|
|
||||||
|
$node = $this->createArticle('https://' . $this->youtu_be_url . $this->youtube_id . ' some text', $this->filter_type);
|
||||||
|
$this->drupalGet('/node/' . $node->id());
|
||||||
|
$this->assertStatusCodeEquals(200);
|
||||||
|
$this->assertElementNotExistsXpath('//span[@class="url-to-video-container youtube-container no-js"]');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testVimeoEmbed()
|
||||||
|
{
|
||||||
|
$this->setFilterSettings(TRUE, TRUE);
|
||||||
|
$node = $this->createArticle('https://' . $this->vimeo_url . $this->vimeo_id . ' some text', $this->filter_type);
|
||||||
|
$this->drupalGet('/node/' . $node->id());
|
||||||
|
$this->assertStatusCodeEquals(200);
|
||||||
|
$this->assertElementExistsXpath('//span[@class="url-to-video-container vimeo-container no-js"]/span[@data-vimeo-id="' . $this->vimeo_id . '"]');
|
||||||
|
|
||||||
|
$node = $this->createArticle('http://' . $this->vimeo_url . $this->vimeo_id . ' some text', $this->filter_type);
|
||||||
|
$this->drupalGet('/node/' . $node->id());
|
||||||
|
$this->assertStatusCodeEquals(200);
|
||||||
|
$this->assertElementExistsXpath('//span[@class="url-to-video-container vimeo-container no-js"]/span[@data-vimeo-id="' . $this->vimeo_id . '"]');
|
||||||
|
|
||||||
|
$node = $this->createArticle('some text https://' . $this->vimeo_url . $this->vimeo_id, $this->filter_type);
|
||||||
|
$this->drupalGet('/node/' . $node->id());
|
||||||
|
$this->assertStatusCodeEquals(200);
|
||||||
|
$this->assertElementExistsXpath('//span[@class="url-to-video-container vimeo-container no-js"]/span[@data-vimeo-id="' . $this->vimeo_id . '"]');
|
||||||
|
|
||||||
|
$node = $this->createArticle('some text http://' . $this->vimeo_url . $this->vimeo_id, $this->filter_type);
|
||||||
|
$this->drupalGet('/node/' . $node->id());
|
||||||
|
$this->assertStatusCodeEquals(200);
|
||||||
|
$this->assertElementExistsXpath('//span[@class="url-to-video-container vimeo-container no-js"]/span[@data-vimeo-id="' . $this->vimeo_id . '"]');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testVimeoNotEmbed()
|
||||||
|
{
|
||||||
|
$this->setFilterSettings(TRUE, FALSE);
|
||||||
|
|
||||||
|
$node = $this->createArticle('https://' . $this->vimeo_url . $this->vimeo_id . ' some text', $this->filter_type);
|
||||||
|
$this->drupalGet('/node/' . $node->id());
|
||||||
|
$this->assertStatusCodeEquals(200);
|
||||||
|
$this->assertElementNotExistsXpath('//span[@class="url-to-video-container vimeo-container no-js"]');
|
||||||
|
}
|
||||||
|
|
||||||
|
private function setFilterSettings($enableYouTube, $enableVimeo)
|
||||||
|
{
|
||||||
|
$this->drupalGet('/admin/config/content/formats/manage/video_filter');
|
||||||
|
$this->assertStatusCodeEquals(200);
|
||||||
|
$youtube_checkbox = '#edit-filters-filter-url-to-video-settings-youtube';
|
||||||
|
$youtube_enabled = $this->checkboxIsChecked($youtube_checkbox);
|
||||||
|
$vimeo_checkbox = '#edit-filters-filter-url-to-video-settings-vimeo';
|
||||||
|
$vimeo_enabled = $this->checkboxIsChecked($vimeo_checkbox);
|
||||||
|
if($enableYouTube && !$youtube_enabled)
|
||||||
|
{
|
||||||
|
$this->checkCheckbox($youtube_checkbox);
|
||||||
|
}
|
||||||
|
elseif(!$enableYouTube && $youtube_enabled)
|
||||||
|
{
|
||||||
|
$this->uncheckCheckbox($youtube_checkbox);
|
||||||
|
}
|
||||||
|
|
||||||
|
if($enableVimeo && !$vimeo_enabled)
|
||||||
|
{
|
||||||
|
$this->checkCheckbox($vimeo_checkbox);
|
||||||
|
}
|
||||||
|
elseif(!$enableVimeo && $vimeo_enabled)
|
||||||
|
{
|
||||||
|
$this->uncheckCheckbox($vimeo_checkbox);
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->click('#edit-actions-submit');
|
||||||
|
$this->assertStatusCodeEquals(200);
|
||||||
|
$this->drupalGet('/admin/config/content/formats/manage/video_filter');
|
||||||
|
$this->assertStatusCodeEquals(200);
|
||||||
|
|
||||||
|
if($enableYouTube)
|
||||||
|
{
|
||||||
|
$this->assertCheckboxChecked($youtube_checkbox);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$this->assertCheckboxNotChecked($youtube_checkbox);
|
||||||
|
}
|
||||||
|
|
||||||
|
if($enableVimeo)
|
||||||
|
{
|
||||||
|
$this->assertCheckboxChecked($vimeo_checkbox);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$this->assertCheckboxNotChecked($vimeo_checkbox);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
+115
@@ -0,0 +1,115 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Drupal\Tests\url_to_video_filter\FunctionalJavascript;
|
||||||
|
|
||||||
|
use Drupal\FunctionalJavascriptTests\JavascriptTestBase;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @group fancy_login
|
||||||
|
*/
|
||||||
|
class UrlToVideoFilterFunctionalJavascriptTestBase extends JavascriptTestBase
|
||||||
|
{
|
||||||
|
public function assertStatusCodeEquals($statusCode)
|
||||||
|
{
|
||||||
|
$this->assertSession()->statusCodeEquals($statusCode);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function assertElementExists($selector)
|
||||||
|
{
|
||||||
|
$this->assertSession()->elementExists('css', $selector);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function assertElementExistsXpath($selector)
|
||||||
|
{
|
||||||
|
$this->assertSession()->elementExists('xpath', $selector);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function assertElementNotExistsXpath($selector)
|
||||||
|
{
|
||||||
|
$this->assertSession()->elementNotExists('xpath', $selector);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getHtml()
|
||||||
|
{
|
||||||
|
$this->assertEquals('', $this->getSession()->getPage()->getHTML());
|
||||||
|
}
|
||||||
|
|
||||||
|
public function clickByXpath($path)
|
||||||
|
{
|
||||||
|
$this->getSession()->getPage()->find('xpath', $path)->click();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function fillTextValue($htmlID, $value)
|
||||||
|
{
|
||||||
|
if(preg_match('/^#/', $htmlID))
|
||||||
|
{
|
||||||
|
$htmlID = substr($htmlID, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->getSession()->getPage()->fillField($htmlID, $value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function checkCheckbox($htmlID)
|
||||||
|
{
|
||||||
|
if(preg_match('/^#/', $htmlID))
|
||||||
|
{
|
||||||
|
$htmlID = substr($htmlID, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->getSession()->getPage()->checkField($htmlID);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function uncheckCheckbox($htmlID)
|
||||||
|
{
|
||||||
|
if(preg_match('/^#/', $htmlID))
|
||||||
|
{
|
||||||
|
$htmlID = substr($htmlID, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->getSession()->getPage()->uncheckField($htmlID);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function assertCheckboxChecked($htmlID)
|
||||||
|
{
|
||||||
|
if(preg_match('/^#/', $htmlID))
|
||||||
|
{
|
||||||
|
$htmlID = substr($htmlID, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->assertSession()->checkboxChecked($htmlID);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function assertCheckboxNotChecked($htmlID)
|
||||||
|
{
|
||||||
|
if(preg_match('/^#/', $htmlID))
|
||||||
|
{
|
||||||
|
$htmlID = substr($htmlID, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->assertSession()->checkboxNotChecked($htmlID);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function checkboxIsChecked($htmlID)
|
||||||
|
{
|
||||||
|
$script = '(function($){return $("' . $htmlID . ':checked").length;}(jQuery));';
|
||||||
|
|
||||||
|
return (bool) $this->getSession()->evaluateScript($script);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function createArticle($body = '', $format = '')
|
||||||
|
{
|
||||||
|
$settings = ['type' => 'article', 'title' => 'Article'];
|
||||||
|
|
||||||
|
if($body)
|
||||||
|
{
|
||||||
|
$settings['body']['value'] = $body;
|
||||||
|
}
|
||||||
|
|
||||||
|
if($format)
|
||||||
|
{
|
||||||
|
$settings['body']['format'] = $format;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->createNode($settings);
|
||||||
|
}
|
||||||
|
}
|
||||||
+71
@@ -0,0 +1,71 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Drupal\Tests\url_to_video_filter\Unit\Service;
|
||||||
|
|
||||||
|
use Drupal\Tests\UnitTestCase;
|
||||||
|
use Drupal\url_to_video_filter\Service\UrlToVideoFilterService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @coversDefaultClass \Drupal\url_to_video_filter\Service\UrlToVideoFilterService
|
||||||
|
* @group url_to_video_filter
|
||||||
|
*/
|
||||||
|
class UrlToVideoFilterServiceTest extends UnitTestCase
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @covers ::convertYouTubeUrls
|
||||||
|
* @dataProvider convertYouTubeUrlsDataProvider
|
||||||
|
*/
|
||||||
|
public function testConvertYouTubeUrls($text, $expected, $findUrls, $message)
|
||||||
|
{
|
||||||
|
$service = new UrlToVideoFilterService();
|
||||||
|
|
||||||
|
$converted = $service->convertYouTubeUrls($text);
|
||||||
|
$this->assertSame($converted['text'], $expected, $message);
|
||||||
|
$this->assertSame($converted['url_found'], $findUrls, $message);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Data provider for testConvertYouTubeUrls()
|
||||||
|
*/
|
||||||
|
public function convertYouTubeUrlsDataProvider()
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
['https://www.youtube.com/watch?v=youtubetest some text', '<span class="url-to-video-container youtube-container no-js"><span class="youtube-player url-to-video-player loader" data-youtube-id="youtubetest"></span></span> some text', TRUE, 'HTTPS Youtube properly embedded at start of string'],
|
||||||
|
['http://www.youtube.com/watch?v=youtubetest some text', '<span class="url-to-video-container youtube-container no-js"><span class="youtube-player url-to-video-player loader" data-youtube-id="youtubetest"></span></span> some text', TRUE, 'HTTP Youtube properly embedded at start of string'],
|
||||||
|
['some text https://www.youtube.com/watch?v=youtubetest', 'some text <span class="url-to-video-container youtube-container no-js"><span class="youtube-player url-to-video-player loader" data-youtube-id="youtubetest"></span></span>', TRUE, 'HTTPS Youtube properly embedded at end of string'],
|
||||||
|
['some text http://www.youtube.com/watch?v=youtubetest', 'some text <span class="url-to-video-container youtube-container no-js"><span class="youtube-player url-to-video-player loader" data-youtube-id="youtubetest"></span></span>', TRUE, 'HTTP Youtube properly embedded at end of string'],
|
||||||
|
['https://youtu.be/youtubetest some text', '<span class="url-to-video-container youtube-container no-js"><span class="youtube-player url-to-video-player loader" data-youtube-id="youtubetest"></span></span> some text', TRUE, 'HTTPS youtu.be properly embedded at start of string'],
|
||||||
|
['http://youtu.be/youtubetest some text', '<span class="url-to-video-container youtube-container no-js"><span class="youtube-player url-to-video-player loader" data-youtube-id="youtubetest"></span></span> some text', TRUE, 'HTTP youtu.be properly embedded at start of string'],
|
||||||
|
['some text https://youtu.be/youtubetest', 'some text <span class="url-to-video-container youtube-container no-js"><span class="youtube-player url-to-video-player loader" data-youtube-id="youtubetest"></span></span>', TRUE, 'HTTPS youtu.be properly embedded at end of string'],
|
||||||
|
['some text http://youtu.be/youtubetest', 'some text <span class="url-to-video-container youtube-container no-js"><span class="youtube-player url-to-video-player loader" data-youtube-id="youtubetest"></span></span>', TRUE, 'HTTP youtu.be properly embedded at end of string'],
|
||||||
|
['some text', 'some text', FALSE, 'Text not converted when no YouTube link exists'],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @covers ::convertVimeoUrls
|
||||||
|
* @dataProvider convertVimeoUrlsDataProvider
|
||||||
|
*/
|
||||||
|
public function testConvertVimeoUrls($text, $expected, $findUrls, $message)
|
||||||
|
{
|
||||||
|
$service = new UrlToVideoFilterService();
|
||||||
|
|
||||||
|
$converted = $service->convertVimeoUrls($text);
|
||||||
|
$this->assertSame($converted['text'], $expected, $message);
|
||||||
|
$this->assertSame($converted['url_found'], $findUrls, $message);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Data provider for testConvertVimeoUrls()
|
||||||
|
*/
|
||||||
|
public function convertVimeoUrlsDataProvider()
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
['https://vimeo.com/vimeotest some text', '<span class="url-to-video-container vimeo-container no-js"><span class="vimeo-player url-to-video-player loader" data-vimeo-id="vimeotest"></span></span> some text', TRUE, 'HTTPS Vimeo properly embedded at start of string'],
|
||||||
|
['http://vimeo.com/vimeotest some text', '<span class="url-to-video-container vimeo-container no-js"><span class="vimeo-player url-to-video-player loader" data-vimeo-id="vimeotest"></span></span> some text', TRUE, 'HTTP Vimeo properly embedded at start of string'],
|
||||||
|
['some text https://vimeo.com/vimeotest', 'some text <span class="url-to-video-container vimeo-container no-js"><span class="vimeo-player url-to-video-player loader" data-vimeo-id="vimeotest"></span></span>', TRUE, 'HTTPS Vimeo properly embedded at end of string'],
|
||||||
|
['some text https://vimeo.com/vimeotest', 'some text <span class="url-to-video-container vimeo-container no-js"><span class="vimeo-player url-to-video-player loader" data-vimeo-id="vimeotest"></span></span>', TRUE, 'HTTP Vimeo properly embedded at end of string'],
|
||||||
|
['some text', 'some text', FALSE, 'Text not converted when no Vimeo link exists'],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
name: Url to video filter
|
||||||
|
description: Text filter to convert URLs to embedded videos
|
||||||
|
type: module
|
||||||
|
# core: 8.x
|
||||||
|
|
||||||
|
configure: 'admin/config/media/url_to_video_filter'
|
||||||
|
|
||||||
|
# Information added by Drupal.org packaging script on 2017-04-10
|
||||||
|
version: '8.x-1.1'
|
||||||
|
core: '8.x'
|
||||||
|
project: 'url_to_video_filter'
|
||||||
|
datestamp: 1491842044
|
||||||
+21
@@ -0,0 +1,21 @@
|
|||||||
|
player_embed:
|
||||||
|
css:
|
||||||
|
theme:
|
||||||
|
css/url_to_video_embed.css: {}
|
||||||
|
|
||||||
|
youtube_embed:
|
||||||
|
js:
|
||||||
|
js/youtube_embed.js: {}
|
||||||
|
dependencies:
|
||||||
|
- core/jquery
|
||||||
|
- core/drupalSettings
|
||||||
|
- core/jquery.once
|
||||||
|
- url_to_video_filter/player_embed
|
||||||
|
|
||||||
|
vimeo_embed:
|
||||||
|
js:
|
||||||
|
js/vimeo_embed.js: {}
|
||||||
|
dependencies:
|
||||||
|
- core/jquery
|
||||||
|
- core/drupalSettings
|
||||||
|
- url_to_video_filter/player_embed
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
parameters:
|
||||||
|
url_to_video_filter.service.class: Drupal\url_to_video_filter\Service\UrlToVideoFilterService
|
||||||
|
|
||||||
|
services:
|
||||||
|
url_to_video_filter.service:
|
||||||
|
class: '%url_to_video_filter.service.class%'
|
||||||
@@ -30,6 +30,7 @@ edlp_vars = {
|
|||||||
var _$corpus_canvas;
|
var _$corpus_canvas;
|
||||||
var _$content_container = $('main[role="main"]>.layout-content');
|
var _$content_container = $('main[role="main"]>.layout-content');
|
||||||
var _$ajaxLinks;
|
var _$ajaxLinks;
|
||||||
|
var _audio_player;
|
||||||
|
|
||||||
function init(){
|
function init(){
|
||||||
console.log("EdlpTheme init()");
|
console.log("EdlpTheme init()");
|
||||||
@@ -332,6 +333,11 @@ edlp_vars = {
|
|||||||
_$body.addClass('ajax-loading');
|
_$body.addClass('ajax-loading');
|
||||||
$link.addClass('ajax-loading');
|
$link.addClass('ajax-loading');
|
||||||
|
|
||||||
|
// TODO: use Drupal.url()
|
||||||
|
// Drupal.url = function (path) {
|
||||||
|
// return drupalSettings.path.baseUrl + drupalSettings.path.pathPrefix + path;
|
||||||
|
// };
|
||||||
|
|
||||||
var path = window.location.origin + drupalSettings.path.baseUrl + ajax_path;
|
var path = window.location.origin + drupalSettings.path.baseUrl + ajax_path;
|
||||||
$.getJSON(path, {})
|
$.getJSON(path, {})
|
||||||
.done(function(data){
|
.done(function(data){
|
||||||
@@ -392,6 +398,9 @@ edlp_vars = {
|
|||||||
|
|
||||||
_$body.trigger({'type':'new-content-ajax-loaded'});
|
_$body.trigger({'type':'new-content-ajax-loaded'});
|
||||||
|
|
||||||
|
// TODO: call behaviours
|
||||||
|
Drupal.attachBehaviors(_$content_container);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// ___
|
// ___
|
||||||
@@ -411,6 +420,8 @@ edlp_vars = {
|
|||||||
console.log('theme : corpus-cliked-on-node', e);
|
console.log('theme : corpus-cliked-on-node', e);
|
||||||
_audio_player.openDocument(e.target_node);
|
_audio_player.openDocument(e.target_node);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
_$body.attr('corpus-map', 'ready');
|
||||||
}
|
}
|
||||||
|
|
||||||
// ___ _ _ _
|
// ___ _ _ _
|
||||||
|
|||||||
@@ -1110,16 +1110,16 @@ header[role="banner"] {
|
|||||||
|
|
||||||
main[role="main"] {
|
main[role="main"] {
|
||||||
z-index: 1;
|
z-index: 1;
|
||||||
pointer-events: none;
|
|
||||||
position: absolute;
|
position: absolute;
|
||||||
left: 0;
|
left: 0;
|
||||||
top: 0;
|
top: 0;
|
||||||
-webkit-box-sizing: border-box;
|
-webkit-box-sizing: border-box;
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
padding: 7em 2em 9em;
|
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: 100%;
|
padding: 7em 2em 9em;
|
||||||
overflow: hidden; }
|
overflow: hidden;
|
||||||
|
pointer-events: none;
|
||||||
|
height: auto; }
|
||||||
main[role="main"] .layout-content {
|
main[role="main"] .layout-content {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
@@ -1130,6 +1130,9 @@ main[role="main"] {
|
|||||||
main[role="main"] .layout-content > * {
|
main[role="main"] .layout-content > * {
|
||||||
pointer-events: auto; }
|
pointer-events: auto; }
|
||||||
|
|
||||||
|
body[corpus-map="ready"] main[role="main"] {
|
||||||
|
height: 100%; }
|
||||||
|
|
||||||
footer[role="contentinfo"] {
|
footer[role="contentinfo"] {
|
||||||
z-index: 2;
|
z-index: 2;
|
||||||
position: fixed;
|
position: fixed;
|
||||||
@@ -2138,3 +2141,27 @@ footer {
|
|||||||
position: absolute;
|
position: absolute;
|
||||||
top: 1em;
|
top: 1em;
|
||||||
right: 1em; }
|
right: 1em; }
|
||||||
|
|
||||||
|
.url-to-video-container {
|
||||||
|
margin: 10px auto; }
|
||||||
|
.url-to-video-container.no-js {
|
||||||
|
border: solid black 1px; }
|
||||||
|
.url-to-video-container.no-js .url-to-video-player {
|
||||||
|
cursor: auto; }
|
||||||
|
.url-to-video-container .loader {
|
||||||
|
top: auto;
|
||||||
|
left: auto;
|
||||||
|
-webkit-transform: none;
|
||||||
|
transform: none; }
|
||||||
|
.url-to-video-container span.url-to-video-player {
|
||||||
|
/* assuming that the video has a 16:9 ratio */
|
||||||
|
padding-bottom: 0;
|
||||||
|
height: auto; }
|
||||||
|
.url-to-video-container span.url-to-video-player:before {
|
||||||
|
content: "";
|
||||||
|
display: block;
|
||||||
|
/* assuming that the video has a 16:9 ratio */
|
||||||
|
padding-top: 56.25%; }
|
||||||
|
.url-to-video-container span.url-to-video-player .play-button {
|
||||||
|
z-index: 5;
|
||||||
|
top: 50%; }
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
var _$corpus_canvas;
|
var _$corpus_canvas;
|
||||||
var _$content_container = $('main[role="main"]>.layout-content');
|
var _$content_container = $('main[role="main"]>.layout-content');
|
||||||
var _$ajaxLinks;
|
var _$ajaxLinks;
|
||||||
|
var _audio_player;
|
||||||
|
|
||||||
function init(){
|
function init(){
|
||||||
console.log("EdlpTheme init()");
|
console.log("EdlpTheme init()");
|
||||||
@@ -309,6 +310,11 @@
|
|||||||
_$body.addClass('ajax-loading');
|
_$body.addClass('ajax-loading');
|
||||||
$link.addClass('ajax-loading');
|
$link.addClass('ajax-loading');
|
||||||
|
|
||||||
|
// TODO: use Drupal.url()
|
||||||
|
// Drupal.url = function (path) {
|
||||||
|
// return drupalSettings.path.baseUrl + drupalSettings.path.pathPrefix + path;
|
||||||
|
// };
|
||||||
|
|
||||||
var path = window.location.origin + drupalSettings.path.baseUrl + ajax_path;
|
var path = window.location.origin + drupalSettings.path.baseUrl + ajax_path;
|
||||||
$.getJSON(path, {})
|
$.getJSON(path, {})
|
||||||
.done(function(data){
|
.done(function(data){
|
||||||
@@ -369,6 +375,9 @@
|
|||||||
|
|
||||||
_$body.trigger({'type':'new-content-ajax-loaded'});
|
_$body.trigger({'type':'new-content-ajax-loaded'});
|
||||||
|
|
||||||
|
// TODO: call behaviours
|
||||||
|
Drupal.attachBehaviors(_$content_container);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// ___
|
// ___
|
||||||
@@ -388,6 +397,8 @@
|
|||||||
console.log('theme : corpus-cliked-on-node', e);
|
console.log('theme : corpus-cliked-on-node', e);
|
||||||
_audio_player.openDocument(e.target_node);
|
_audio_player.openDocument(e.target_node);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
_$body.attr('corpus-map', 'ready');
|
||||||
}
|
}
|
||||||
|
|
||||||
// ___ _ _ _
|
// ___ _ _ _
|
||||||
|
|||||||
@@ -1148,3 +1148,90 @@ footer{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// __ ___ _ ___ _ _ _
|
||||||
|
// \ \ / (_)__| |___ ___| __(_) | |_ ___ _ _
|
||||||
|
// \ V /| / _` / -_) _ \ _|| | | _/ -_) '_|
|
||||||
|
// \_/ |_\__,_\___\___/_| |_|_|\__\___|_|
|
||||||
|
// complete rewrite of url_to_video_filter css
|
||||||
|
.url-to-video-container{
|
||||||
|
// display:block;
|
||||||
|
margin:10px auto;
|
||||||
|
// width:100%;
|
||||||
|
&.no-js{
|
||||||
|
border:solid black 1px;
|
||||||
|
.loader{
|
||||||
|
// background:url(../images/no-js.png) no-repeat center center;
|
||||||
|
// background-size:40px 40px;
|
||||||
|
}
|
||||||
|
.url-to-video-player{
|
||||||
|
cursor:auto;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.loader{
|
||||||
|
// top:240px;
|
||||||
|
// left:50%;
|
||||||
|
// transform:translate(-50%, -50%);
|
||||||
|
// background:#FFF url(../images/ajax-loader.gif) no-repeat center center;
|
||||||
|
top:auto; left: auto;
|
||||||
|
transform: none;
|
||||||
|
}
|
||||||
|
span.url-to-video-player{
|
||||||
|
// display:block;
|
||||||
|
// width:100%;
|
||||||
|
/* assuming that the video has a 16:9 ratio */
|
||||||
|
// padding-bottom:56.25%;
|
||||||
|
padding-bottom:0;
|
||||||
|
// overflow:hidden;
|
||||||
|
// position:relative;
|
||||||
|
// width:100%;
|
||||||
|
// height:100%;
|
||||||
|
height:auto;
|
||||||
|
// cursor:hand;
|
||||||
|
// cursor:pointer;
|
||||||
|
// display: block;
|
||||||
|
&:before{
|
||||||
|
content: "";
|
||||||
|
display: block;
|
||||||
|
/* assuming that the video has a 16:9 ratio */
|
||||||
|
padding-top: 56.25%;
|
||||||
|
}
|
||||||
|
img.player-thumb
|
||||||
|
{
|
||||||
|
// background-position:center center;
|
||||||
|
// background-size:cover;
|
||||||
|
// position: absolute;
|
||||||
|
// top: 0;
|
||||||
|
// left: 0;
|
||||||
|
// width: 100%;
|
||||||
|
// height: 100%;
|
||||||
|
// cursor:pointer;
|
||||||
|
}
|
||||||
|
.play-button
|
||||||
|
{
|
||||||
|
z-index: 5;
|
||||||
|
// height:40px;
|
||||||
|
// width:40px;
|
||||||
|
// display:block;
|
||||||
|
// background:url(../images/play-button.png) no-repeat center center;
|
||||||
|
// background-size:40px 40px;
|
||||||
|
// position:absolute;
|
||||||
|
// top:240px;
|
||||||
|
top:50%;
|
||||||
|
// left:50%;
|
||||||
|
// transform:translate(-50%, -50%);
|
||||||
|
// cursor:pointer;
|
||||||
|
}
|
||||||
|
iframe.player-iframe
|
||||||
|
{
|
||||||
|
// width:100%;
|
||||||
|
// height:100%;
|
||||||
|
// position:absolute;
|
||||||
|
// top:0;
|
||||||
|
// left:0;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -40,13 +40,14 @@ header[role="banner"]{
|
|||||||
main[role="main"]{
|
main[role="main"]{
|
||||||
// outline:1px solid green;
|
// outline:1px solid green;
|
||||||
z-index: 1;
|
z-index: 1;
|
||||||
pointer-events: none;
|
|
||||||
position: absolute;
|
position: absolute;
|
||||||
left:0; top:0;
|
left:0; top:0;
|
||||||
box-sizing:border-box;
|
box-sizing:border-box;
|
||||||
|
width:100%;
|
||||||
padding:7em 2em 9em;
|
padding:7em 2em 9em;
|
||||||
width:100%; height:100%;
|
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
|
pointer-events: none;
|
||||||
|
height:auto;
|
||||||
.layout-content{
|
.layout-content{
|
||||||
width: 100%; height:100%;
|
width: 100%; height:100%;
|
||||||
overflow:hidden;
|
overflow:hidden;
|
||||||
@@ -60,6 +61,11 @@ main[role="main"]{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
body[corpus-map="ready"] main[role="main"]{
|
||||||
|
height:100%;
|
||||||
|
// overflow-y: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
footer[role="contentinfo"]{
|
footer[role="contentinfo"]{
|
||||||
// outline: 1px solid pink;
|
// outline: 1px solid pink;
|
||||||
z-index: 2;
|
z-index: 2;
|
||||||
|
|||||||
@@ -17,7 +17,11 @@ global-js:
|
|||||||
assets/dist/scripts/main.min.js: { scope: footer }
|
assets/dist/scripts/main.min.js: { scope: footer }
|
||||||
dependencies:
|
dependencies:
|
||||||
- core/drupal
|
- core/drupal
|
||||||
|
- core/drupal.ajax
|
||||||
- core/matchmedia
|
- core/matchmedia
|
||||||
- core/matchmedia.addListener
|
- core/matchmedia.addListener
|
||||||
- core/jquery
|
- core/jquery
|
||||||
- core/jquery.once
|
- core/jquery.once
|
||||||
|
- url_to_video_filter/player_embed
|
||||||
|
- url_to_video_filter/vimeo_embed
|
||||||
|
- url_to_video_filter/youtube_embed
|
||||||
|
|||||||
@@ -71,6 +71,7 @@ module:
|
|||||||
text: 0
|
text: 0
|
||||||
toolbar: 0
|
toolbar: 0
|
||||||
update: 0
|
update: 0
|
||||||
|
url_to_video_filter: 0
|
||||||
user: 0
|
user: 0
|
||||||
views: 0
|
views: 0
|
||||||
views_bulk_edit: 0
|
views_bulk_edit: 0
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ dependencies:
|
|||||||
module:
|
module:
|
||||||
- editor
|
- editor
|
||||||
- edlp_corpus
|
- edlp_corpus
|
||||||
|
- url_to_video_filter
|
||||||
name: wysiwyg
|
name: wysiwyg
|
||||||
format: wysiwyg
|
format: wysiwyg
|
||||||
weight: 0
|
weight: 0
|
||||||
@@ -19,13 +20,13 @@ filters:
|
|||||||
id: filter_html_image_secure
|
id: filter_html_image_secure
|
||||||
provider: filter
|
provider: filter
|
||||||
status: true
|
status: true
|
||||||
weight: -47
|
weight: -48
|
||||||
settings: { }
|
settings: { }
|
||||||
filter_url:
|
filter_url:
|
||||||
id: filter_url
|
id: filter_url
|
||||||
provider: filter
|
provider: filter
|
||||||
status: true
|
status: true
|
||||||
weight: -48
|
weight: -45
|
||||||
settings:
|
settings:
|
||||||
filter_url_length: 72
|
filter_url_length: 72
|
||||||
filter_autop:
|
filter_autop:
|
||||||
@@ -38,13 +39,13 @@ filters:
|
|||||||
id: filter_htmlcorrector
|
id: filter_htmlcorrector
|
||||||
provider: filter
|
provider: filter
|
||||||
status: true
|
status: true
|
||||||
weight: -46
|
weight: -47
|
||||||
settings: { }
|
settings: { }
|
||||||
filter_html:
|
filter_html:
|
||||||
id: filter_html
|
id: filter_html
|
||||||
provider: filter
|
provider: filter
|
||||||
status: false
|
status: false
|
||||||
weight: -44
|
weight: -43
|
||||||
settings:
|
settings:
|
||||||
allowed_html: '<em> <strong> <cite> <blockquote cite> <code> <ul type> <ol start type> <li> <dl> <dt> <dd> <h2 id> <h3 id> <h4 id> <h5 id> <h6 id> <u> <a href hreflang !href accesskey id rel target title> <img src alt data-entity-type data-entity-uuid>'
|
allowed_html: '<em> <strong> <cite> <blockquote cite> <code> <ul type> <ol start type> <li> <dl> <dt> <dd> <h2 id> <h3 id> <h4 id> <h5 id> <h6 id> <u> <a href hreflang !href accesskey id rel target title> <img src alt data-entity-type data-entity-uuid>'
|
||||||
filter_html_help: true
|
filter_html_help: true
|
||||||
@@ -53,23 +54,33 @@ filters:
|
|||||||
id: audio_links
|
id: audio_links
|
||||||
provider: edlp_corpus
|
provider: edlp_corpus
|
||||||
status: true
|
status: true
|
||||||
weight: -45
|
weight: -44
|
||||||
settings: { }
|
settings: { }
|
||||||
filter_align:
|
filter_align:
|
||||||
id: filter_align
|
id: filter_align
|
||||||
provider: filter
|
provider: filter
|
||||||
status: false
|
status: false
|
||||||
weight: -42
|
weight: -41
|
||||||
settings: { }
|
settings: { }
|
||||||
filter_caption:
|
filter_caption:
|
||||||
id: filter_caption
|
id: filter_caption
|
||||||
provider: filter
|
provider: filter
|
||||||
status: false
|
status: false
|
||||||
weight: -41
|
weight: -40
|
||||||
settings: { }
|
settings: { }
|
||||||
filter_html_escape:
|
filter_html_escape:
|
||||||
id: filter_html_escape
|
id: filter_html_escape
|
||||||
provider: filter
|
provider: filter
|
||||||
status: false
|
status: false
|
||||||
weight: -43
|
weight: -42
|
||||||
settings: { }
|
settings: { }
|
||||||
|
filter_url_to_video:
|
||||||
|
id: filter_url_to_video
|
||||||
|
provider: url_to_video_filter
|
||||||
|
status: true
|
||||||
|
weight: -46
|
||||||
|
settings:
|
||||||
|
youtube: '1'
|
||||||
|
youtube_webp_preview: '0'
|
||||||
|
vimeo: '1'
|
||||||
|
autoload: '0'
|
||||||
|
|||||||
Reference in New Issue
Block a user