はじまりの大地
This commit is contained in:
@@ -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,17 @@
|
||||
<?php
|
||||
/**
|
||||
* Default settings for the oembed plugin
|
||||
*
|
||||
* @author Dwayne Bent <dbb.pub0@liqd.org>
|
||||
* @author nik gaffney <nik@fo.am>
|
||||
*/
|
||||
|
||||
$conf['resolution_priority'] = 'link discovery';
|
||||
|
||||
$conf['enable_direct_link'] = 1;
|
||||
$conf['enable_link_discovery'] = 1;
|
||||
$conf['enable_provider_list'] = 1;
|
||||
|
||||
$conf['format_preference'] = 'json';
|
||||
|
||||
$conf['fullwidth_images'] = 1;
|
||||
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
/**
|
||||
* Options for the oembed plugin
|
||||
*
|
||||
* @author Dwayne Bent <dbb.pub0@liqd.org>
|
||||
* @author nik gaffney <nik@fo.am>
|
||||
*/
|
||||
|
||||
$meta['resolution_priority'] = array('multichoice','_choices' => array('link discovery','provider list'));
|
||||
|
||||
$meta['enable_direct_link'] = array('onoff');
|
||||
$meta['enable_link_discovery'] = array('onoff');
|
||||
$meta['enable_provider_list'] = array('onoff');
|
||||
|
||||
$meta['format_preference'] = array('multichoice','_choices' => array('xml','json'));
|
||||
|
||||
$meta['fullwidth_images'] = array('onoff');
|
||||
@@ -0,0 +1,69 @@
|
||||
# -*- mode: org; coding: utf-8; -*-
|
||||
|
||||
* oEmbed Plugin
|
||||
|
||||
#+BEGIN_SRC dokuwiki
|
||||
---- plugin ----
|
||||
description: Easily embed media from OEmbed providers.
|
||||
author : Dwayne Bent, nik gaffney
|
||||
email : nik@fo.am
|
||||
type : syntax
|
||||
lastupdate : 2019-09-01
|
||||
compatible : Greebo
|
||||
depends :
|
||||
conflicts :
|
||||
similar :
|
||||
tags : media, images, video, music, embed
|
||||
|
||||
downloadurl: https://github.com/zzkt/dokuwiki-oembed/zipball/master
|
||||
sourcerepo : https://github.com/zzkt/dokuwiki-oembed/
|
||||
bugtracker : https://github.com/zzkt/dokuwiki-oembed/issues
|
||||
donationurl: https://www.sarcoma.org.au/donations
|
||||
|
||||
----
|
||||
#+END_SRC
|
||||
|
||||
The oEmbed plugin allows you to easily embed media from any provider that supports the [[https://oembed.com/][oEmbed]] format.
|
||||
|
||||
** Install
|
||||
|
||||
Search for and install the plugin using the [[plugin:extension][Extension Manager]]. Refer to [[:Plugins]] on how to install plugins manually.
|
||||
|
||||
** Syntax
|
||||
|
||||
The simplest way to embed media is with its url. e.g. ~{{>http://example.com/}}~
|
||||
|
||||
Some providers can be given extra options in the form ~{{>url?options}}~ such as ~maxwidth~ or ~maxheight~
|
||||
|
||||
|
||||
|
||||
An oembed provider will specify a URL scheme and API endpoint pairs. If you know the endpoint you can also use the ~!direct~ keyword to send paramaters to the API endpoint
|
||||
|
||||
** Examples
|
||||
|
||||
Embed a single image from Flickr
|
||||
|
||||
~{{>http://www.flickr.com/photos/foam/41018347952}}~~
|
||||
|
||||
embed an image with a maximum width of 800px
|
||||
|
||||
~{{>http://www.flickr.com/photos/foam/41018347952?maxwidth=800}}~~
|
||||
|
||||
embed a gallery
|
||||
|
||||
~{{>http://www.flickr.com/photos/flickr/galleries/72157667259442778/}}~~
|
||||
|
||||
use the API endpoint directly
|
||||
|
||||
~{{>http://www.flickr.com/services/oembed/ !direct ?url=http://www.flickr.com/photos/sdasmarchives/5018415361/}}~
|
||||
|
||||
** Further
|
||||
|
||||
A list of oembed providers can be found on the [[https://oembed.com/][oEmbed website]] and [[https://noembed.com/][Noembed]] can provide a consitent inferface for supported and unsupoprted site.
|
||||
|
||||
** Known issues
|
||||
|
||||
The current plugin (as of 2019) has been updated from an old unmaintained version but doesn't use the new plugin skeleton and may not be fully compatible with current/future versions of dokuwiki.
|
||||
|
||||
- can't resolve https urls for some providers
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
====== oEmbed Plugin ======
|
||||
|
||||
---- plugin ----
|
||||
description: Easily embed media from OEmbed providers.
|
||||
author : Dwayne Bent, nik gaffney
|
||||
email : nik@fo.am
|
||||
type : syntax
|
||||
lastupdate : 2019-09-01
|
||||
compatible : Greebo
|
||||
depends :
|
||||
conflicts :
|
||||
similar :
|
||||
tags : media, images, video, music, embed
|
||||
|
||||
downloadurl: https://github.com/zzkt/dokuwiki-oembed/zipball/master
|
||||
sourcerepo : https://github.com/zzkt/dokuwiki-oembed/
|
||||
bugtracker : https://github.com/zzkt/dokuwiki-oembed/issues
|
||||
donationurl: https://www.sarcoma.org.au/donations
|
||||
|
||||
----
|
||||
|
||||
The oEmbed plugin allows you to easily embed media from any provider that supports the [[https://oembed.com/|oEmbed]] format.
|
||||
|
||||
===== Install =====
|
||||
|
||||
Search for and install the plugin using the [[plugin:extension|Extension Manager]]. Refer to :Plugins on how to install plugins manually.
|
||||
|
||||
===== Syntax =====
|
||||
|
||||
The simplest way to embed media is with its url. e.g. ''%%{{>http://example.com/}}%%''
|
||||
|
||||
Some providers can be given extra options in the form ''%%{{>url?options}}%%'' such as ''%%maxwidth%%'' or ''%%maxheight%%''
|
||||
|
||||
An oembed provider will specify a URL scheme and API endpoint pairs. If you know the endpoint you can also use the ''%%!direct%%'' keyword to send paramaters to the API endpoint
|
||||
|
||||
===== Examples =====
|
||||
|
||||
Embed a single image from Flickr
|
||||
|
||||
''%%{{>http://www.flickr.com/photos/foam/41018347952}}~%%''
|
||||
|
||||
embed an image with a maximum width of 800px
|
||||
|
||||
''%%{{>http://www.flickr.com/photos/foam/41018347952?maxwidth=800}}~%%''
|
||||
|
||||
embed a gallery
|
||||
|
||||
''%%{{>http://www.flickr.com/photos/flickr/galleries/72157667259442778/}}~%%''
|
||||
|
||||
use the API endpoint directly
|
||||
|
||||
''%%{{>http://www.flickr.com/services/oembed/ !direct ?url=http://www.flickr.com/photos/sdasmarchives/5018415361/}}%%''
|
||||
|
||||
===== Further =====
|
||||
|
||||
A list of oembed providers can be found on the [[https://oembed.com/|oEmbed website]] and [[https://noembed.com/|Noembed]] can provide a consitent inferface for supported and unsupoprted site.
|
||||
|
||||
===== Known issues =====
|
||||
|
||||
The current plugin (as of 2019) has been updated from an old unmaintained version but doesn't use the new plugin skeleton and may not be fully compatible with current/future versions of dokuwiki.
|
||||
|
||||
* can't resolve https urls for some providers
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
/**
|
||||
* english language file for oembed plugin
|
||||
*
|
||||
* @author Dwayne Bent <dbb.pub0@liqd.org>
|
||||
* @author nik gaffney <nik@fo.am>
|
||||
*/
|
||||
|
||||
$lang['resolution_priority'] = 'Initial resolution method';
|
||||
|
||||
$lang['enable_direct_link'] = 'Enable !direct links';
|
||||
$lang['enable_link_discovery'] = 'Enable link discovery';
|
||||
$lang['enable_provider_list'] = 'Enable local provider list';
|
||||
|
||||
$lang['format_preference'] = 'Preferred response format';
|
||||
|
||||
$lang['fullwidth_images'] = 'Render full width images only (i.e. <code>width=100%</code>)';
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
downloadurl=https://github.com/zzkt/dokuwiki-oembed/zipball/endless
|
||||
installed=Mon, 08 Jul 2024 02:41:11 +0900
|
||||
updated=Mon, 08 Jul 2024 02:41:48 +0900
|
||||
@@ -0,0 +1,8 @@
|
||||
base oembed
|
||||
author Dwayne Bent, nik gaffney
|
||||
email nik@fo.am
|
||||
date 2020-06-03
|
||||
name oembed plugin
|
||||
desc Embed media from oEmbed providers
|
||||
url https://github.com/zzkt/dokuwiki-oembed/zipball/master
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
<!--
|
||||
Provider List
|
||||
for the DokuWiki OEmbed plugin.
|
||||
|
||||
Important:
|
||||
Due to the risk of a cross-site scripting attack
|
||||
[http://en.wikipedia.org/wiki/Cross-site_scripting] only list providers
|
||||
that you trust. Remove any providers that you do not trust.
|
||||
|
||||
Usage:
|
||||
Each provider element has two attributes: name, which is currently not
|
||||
used and api which is the API endpoint for the provider's OEmbed
|
||||
service. Each provider also lists scheme elements which contain the
|
||||
regular expressions of the URLs for which the API endpoint can be used.
|
||||
The regular expressions are matched agains the entire URL (no need for
|
||||
'^$') and case insensitively. The schemes listed on oembed.com are not
|
||||
valid regular expressions and need to be converted.
|
||||
|
||||
Additional providers can be found in the sample-providers.xml file and
|
||||
a more detailed list of providers can be found on the oembed site
|
||||
https://oembed.com/providers.json
|
||||
|
||||
-->
|
||||
|
||||
<providers>
|
||||
<!-- DIRECT PROVIDERS -->
|
||||
<!-- Flickr -->
|
||||
<provider name="Flickr" api="http://www.flickr.com/services/oembed.xml">
|
||||
<scheme>https?://(.*?\.)?flickr\.com/.*?</scheme>
|
||||
</provider>
|
||||
|
||||
<!-- Twitter -->
|
||||
<provider name="Twitter" api="https://publish.twitter.com/oembed">
|
||||
<scheme>https?://twitter\.com/.*?</scheme>
|
||||
<scheme>https?://www\.twitter\.com/.*?</scheme>
|
||||
</provider>
|
||||
|
||||
<!-- Vimeo -->
|
||||
<provider name="Vimeo" api="http://www.vimeo.com/api/oembed.{format}">
|
||||
<scheme>https?://www\.vimeo\.com/.*?</scheme>
|
||||
<scheme>https?://www\.vimeo\.com/groups/.*?/.*?</scheme>
|
||||
</provider>
|
||||
|
||||
<!-- Youtube -->
|
||||
<provider name="Youtube" api="https://www.youtube.com/oembed">
|
||||
<scheme>https?://(.*?\.)?youtube\.com/watch.*?</scheme>
|
||||
<scheme>https?://(.*?\.)?youtube\.com/v/.*?</scheme>
|
||||
<scheme>https?://youtu\.be/.*?</scheme>
|
||||
<scheme>https?://(.*?\.)?youtube\.com/playlist?list=.*?</scheme>
|
||||
</provider>
|
||||
|
||||
<!-- PROXY PROVIDERS -->
|
||||
|
||||
|
||||
</providers>
|
||||
@@ -0,0 +1,122 @@
|
||||
<!--
|
||||
Provider List
|
||||
for the DokuWiki oEmbed plugin
|
||||
|
||||
Important:
|
||||
Due to the risk of a cross-site scripting attack
|
||||
[http://en.wikipedia.org/wiki/Cross-site_scripting] only list providers
|
||||
that you trust. Remove any providers that you do not trust.
|
||||
|
||||
Usage:
|
||||
Each provider element has two attributes: name, which is currently not
|
||||
used and api which is the API endpoint for the provider's OEmbed
|
||||
service. Each provider also lists scheme elements which contain the
|
||||
regular expressions of the URLs for which the API endpoint can be used.
|
||||
The regular expressions are matched agains the entire URL (no need for
|
||||
'^$') and case insensitively. The schemes listed on oembed.com are not
|
||||
valid regular expressions and need to be converted.
|
||||
|
||||
Providers listed under PROXY PROVIDERS are not content providers but
|
||||
instead act as intermediaries for providers that may or may not natively
|
||||
support oEmbed.
|
||||
|
||||
A more detailed list of providers can be found on the oEmbed site
|
||||
https://oembed.com/providers.json
|
||||
-->
|
||||
|
||||
<providers>
|
||||
<!-- DIRECT PROVIDERS -->
|
||||
<!-- Flickr -->
|
||||
<provider name="Flickr" api="http://www.flickr.com/services/oembed/">
|
||||
<scheme>http://(.*?\.)?flickr\.com/.*?</scheme>
|
||||
</provider>
|
||||
|
||||
<!-- Viddler -->
|
||||
<provider name="Viddler" api="http://lab.viddler.com/services/oembed/">
|
||||
<scheme>http://.*?\.viddler\.com/.*?</scheme>
|
||||
</provider>
|
||||
|
||||
<!-- Qik -->
|
||||
<provider name="Qik" api="http://qik.com/api/oembed.{format}">
|
||||
<scheme>http://qik\.com/video/.*?</scheme>
|
||||
<scheme>http://qik\.com/.*?</scheme>
|
||||
</provider>
|
||||
|
||||
<!-- Pownce -->
|
||||
<provider name="Pownce" api="http://api.pownce.com/2.1/oembed.{format}">
|
||||
<scheme>http://(.*?\.)?pownce\.com/.*?</scheme>
|
||||
</provider>
|
||||
|
||||
<!-- Revision3 -->
|
||||
<provider name="Revision3" api="http://revision3.com/api/oembed/">
|
||||
<scheme>http://(.*?\.)?revision3\.com/.*?</scheme>
|
||||
</provider>
|
||||
|
||||
<!-- Hulu -->
|
||||
<provider name="Hulu" api="http://www.hulu.com/api/oembed.{format}">
|
||||
<scheme>http://www\.hulu\.com/watch/.*?</scheme>
|
||||
</provider>
|
||||
|
||||
<!-- Vimeo -->
|
||||
<provider name="Vimeo" api="http://www.vimeo.com/api/oembed.{format}">
|
||||
<scheme>http://www\.vimeo\.com/.*?</scheme>
|
||||
<scheme>http://www\.vimeo\.com/groups/.*?/.*?</scheme>
|
||||
</provider>
|
||||
|
||||
<!-- PROXY PROVIDERS -->
|
||||
|
||||
<!-- oohEmbed is no longer active as of 2019 -->
|
||||
<provider name="oohEmbed" api="http://oohembed.com/oohembed/">
|
||||
<!-- Amazon Product Image -->
|
||||
<scheme>http://.*?\.amazon\.(com|co\.uk|de|ca|jp)/(gp/product|o/ASIN|obidos/ASIN|dp)/.*?</scheme>
|
||||
|
||||
<!-- CollegeHumor Video -->
|
||||
<scheme>http://.*?\.collegehumor\.com/video:.*?</scheme>
|
||||
|
||||
<!-- Flickr (proxy to native service) -->
|
||||
<scheme>http://(.*?\.)?flickr\.com/photos/.*?</scheme>
|
||||
|
||||
<!-- Funny or Die Video -->
|
||||
<scheme>http://.*?\.funnyordie.com/videos/.*?</scheme>
|
||||
|
||||
<!-- Google Video -->
|
||||
<scheme>http://video\.google\.com/videoplay\?.*?</scheme>
|
||||
|
||||
<!-- Hulu (proxy to native service) -->
|
||||
<scheme>http://www\.hulu\.com/watch/.*?</scheme>
|
||||
|
||||
<!-- IMDb -->
|
||||
<scheme>http://.*?\.imdb\.com/title/tt.*?/</scheme>
|
||||
|
||||
<!-- Metacafe -->
|
||||
<scheme>http://.*?\.metacafe\.com/watch/.*?</scheme>
|
||||
|
||||
<!-- Pownce (proxy to native service) -->
|
||||
<scheme>http://(.*?\.)?pownce\.com/.*?/notes/.*?</scheme>
|
||||
|
||||
<!-- Qik (proxy to native service) -->
|
||||
<scheme>http://qik\.com/.*?</scheme>
|
||||
|
||||
<!-- Revision3 (proxy to native service) -->
|
||||
<scheme>http://(.*?\.)?revision3\.com/.*?</scheme>
|
||||
|
||||
<!-- SlideShare -->
|
||||
<scheme>http://.*?\.slideshare\.net/.*?</scheme>
|
||||
|
||||
<!-- Viddler Video (proxy to native service) -->
|
||||
<scheme>http://.*?\.viddler\.com/explore/.*?</scheme>
|
||||
|
||||
<!-- Vimeo (proxy to native service) -->
|
||||
<scheme>http://www\.vimeo\.com/.*?</scheme>
|
||||
<scheme>http://www\.vimeo\.com/groups/.*?/.*?</scheme>
|
||||
|
||||
<!-- Wikipedia -->
|
||||
<scheme>http://.*?\.wikipedia\.org/wiki/.*?</scheme>
|
||||
|
||||
<!-- Wordpress.com -->
|
||||
<scheme>http://.*?\.wordpress\.com/\d{4}/\d{2}/\d{2}/.*?</scheme>
|
||||
|
||||
<!-- Youtube -->
|
||||
<scheme>http://(.*?\.)?youtube\.com/watch.*?</scheme>
|
||||
</provider>
|
||||
</providers>
|
||||
@@ -0,0 +1,74 @@
|
||||
/*******************************************************************************
|
||||
*
|
||||
* OEMBED CSS STYLE SHEET (v0.2.1) [2008/07/29]
|
||||
* by Dwayne Bent [dbb.pub0@liqd.org]
|
||||
*
|
||||
* Designed for use in the OEmbed plugin [http://liqd.org/wiki/oembed/] for
|
||||
* DokuWiki [http://wiki.splitbrain.org/wiki:dokuwiki].
|
||||
*
|
||||
* Copyright (c) 2008, Dwayne Bent
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
div.dokuwiki .oembed {
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
div.dokuwiki .oembed-center {
|
||||
margin: 0 auto;
|
||||
}
|
||||
|
||||
div.dokuwiki .oembed-right {
|
||||
float: right;
|
||||
}
|
||||
|
||||
div.dokuwiki .oembed-chrome {
|
||||
border: dashed 1px __border__;
|
||||
background-color: __background__;
|
||||
}
|
||||
|
||||
div.dokuwiki .oembed-title {
|
||||
margin: 0px;
|
||||
font-size: 150%;
|
||||
font-weight: bold;
|
||||
padding-left: 1%;
|
||||
padding-right: 1%;
|
||||
padding-top: 0px;
|
||||
}
|
||||
|
||||
div.dokuwiki .oembed-author {
|
||||
padding-left: 1%;
|
||||
padding-bottom: 2px;
|
||||
padding-top: 2px;
|
||||
}
|
||||
|
||||
div.dokuwiki .oembed-chrome > .oembed-content {
|
||||
}
|
||||
|
||||
div.dokuwiki .oembed-provider {
|
||||
padding: 2px 5px 2px 5px;
|
||||
}
|
||||
@@ -0,0 +1,598 @@
|
||||
<?php
|
||||
/**
|
||||
* OEMBED PLUGIN
|
||||
*
|
||||
* Version history
|
||||
* 2008-07-31 - release v0.6 by Dwayne Bent <dbb.pub0@liqd.org>
|
||||
* 2019-09-01 - resuscitation & realignment with "Greebo"
|
||||
*
|
||||
* Licensed under the GPL 2 [http://www.gnu.org/licenses/gpl.html]
|
||||
*
|
||||
**/
|
||||
|
||||
if(!defined('DOKU_INC')) define('DOKU_INC',realpath(dirname(__FILE__).'/../../').'/');
|
||||
if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/');
|
||||
define('OEMBED_BASE',DOKU_PLUGIN.'oembed/');
|
||||
require_once(DOKU_PLUGIN.'syntax.php');
|
||||
require_once(DOKU_INC.'inc/HTTP/HTTPClient.php');
|
||||
|
||||
class syntax_plugin_oembed extends DokuWiki_Syntax_Plugin {
|
||||
var $errors = array();
|
||||
var $version = '1.0';
|
||||
var $regex_master = '/^{{>\s*(?<url>.+?)(?:\s+(?<params>.+?))??\s*}}$/';
|
||||
|
||||
function getType(){
|
||||
return 'substition';
|
||||
}
|
||||
|
||||
function getAllowedTypes() {
|
||||
return array();
|
||||
}
|
||||
|
||||
function getPType(){
|
||||
return 'block';
|
||||
}
|
||||
|
||||
function getSort(){
|
||||
return 285;
|
||||
}
|
||||
|
||||
function connectTo($mode) {
|
||||
$this->Lexer->addSpecialPattern('{{>.+?}}', $mode, 'plugin_oembed');
|
||||
}
|
||||
|
||||
function handle($match, $state, $pos, Doku_Handler $handler){
|
||||
if($state == DOKU_LEXER_SPECIAL){
|
||||
if($parsed_tag = $this->parseTag($match)){
|
||||
$oembed_data = $this->resolve($parsed_tag);
|
||||
return array('oembed_data' => $oembed_data,
|
||||
'tag' => $parsed_tag,
|
||||
'errors' => $this->errors);
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function render($mode, Doku_Renderer $renderer, $data) {
|
||||
if($mode == 'xhtml'){
|
||||
$renderer->doc .= $this->renderXHTML($data);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/***************************************************************************
|
||||
* PARSE FUNCTIONS
|
||||
* Convert input strings to a usable form
|
||||
**************************************************************************/
|
||||
|
||||
/*
|
||||
* Parse the entire matched string
|
||||
*
|
||||
* $tag: The entire matched string
|
||||
*
|
||||
* returns:
|
||||
* false on error otherwise
|
||||
* array of parsed data:
|
||||
* url: the target url
|
||||
* params: array of parsed parameters, see parseParams()
|
||||
*/
|
||||
function parseTag($tag){
|
||||
if(preg_match($this->regex_master, $tag, $matches)){
|
||||
return array('url' => $matches['url'],
|
||||
'params' => $this->parseParams($matches['params']));
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
* Parse the tag parameters
|
||||
*
|
||||
* $params: whitespace delimited list of parameters (no trailing or leading
|
||||
* whitespace)
|
||||
*
|
||||
* returns:
|
||||
* array of parsed parameters:
|
||||
* provider: array of provider parameters:
|
||||
* name => value
|
||||
* plugin: array of plugin parameters
|
||||
* name => value
|
||||
*/
|
||||
function parseParams($params){
|
||||
$parsed_params = array('provider' => array(), 'plugin' => array());
|
||||
|
||||
if($params != null){
|
||||
foreach(preg_split('/\s+/', $params) as $param){
|
||||
if(preg_match('/^(?<type>!|\?)(?<name>\S+?)(?:=(?<value>\S+?))?$/', $param, $matches)){
|
||||
if($matches['type'] == '?'){
|
||||
$parsed_params['provider'][$matches['name']] = $matches['value'];
|
||||
}
|
||||
else if($matches['type'] == '!'){
|
||||
$parsed_params['plugin'][$matches['name']] = $matches['value'];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $parsed_params;
|
||||
}
|
||||
|
||||
/*
|
||||
* Parse an HTTP response containing OEmbed data
|
||||
*
|
||||
* $response: array of HTTP response data
|
||||
* status: numerical HTTP status code
|
||||
* headers: array of HTTP headers
|
||||
* name => value
|
||||
* body: body of the response
|
||||
*
|
||||
* returns: false on error or array of parsed oembed data:
|
||||
* name => value
|
||||
*/
|
||||
function parseResponse($response){
|
||||
if($response['status'] != 200) return $this->error("Provider returned HTTP Status {$response['status']} for {$tag['url']}");
|
||||
if(!$type = $this->parseContentType($response['headers']['content-type'])) return false;
|
||||
|
||||
$oembed = array();
|
||||
|
||||
switch($type){
|
||||
case 'xml':
|
||||
if(!$xml = simplexml_load_string($response['body'])) return $this->error("Unable to parse XML: {$response['body']}");
|
||||
|
||||
foreach($xml as $element){
|
||||
$oembed[$element->getName()] = (string) $element;
|
||||
}
|
||||
|
||||
break;
|
||||
case 'json':
|
||||
$oembed = json_decode($response['body']);
|
||||
|
||||
break;
|
||||
default:
|
||||
return $this->error("Internal error occured. Found type: {$type}");
|
||||
}
|
||||
|
||||
//if($oembed['version'] != '1.0') return $this->error("Unsupported OEmbed version: {$oembed['version']}");
|
||||
return $oembed;
|
||||
}
|
||||
|
||||
/*
|
||||
* Parse a content-type string from an HTTP header
|
||||
*
|
||||
* $header: The content-type string
|
||||
*
|
||||
* returns: false on error or 'json' for JSON content or 'xml' for XML content
|
||||
*/
|
||||
function parseContentType($header){
|
||||
if(!preg_match('/^\s*(?<type>[^;\s]+)(.*)?/', $header, $matches)){
|
||||
return $this->error("Invalid Content-Type header: {$header}");
|
||||
}
|
||||
|
||||
switch($matches['type']){
|
||||
case 'text/xml':
|
||||
return 'xml';
|
||||
case 'application/json':
|
||||
return 'json';
|
||||
// non-spec content-types, only supported for compatibility
|
||||
case 'application/xml':
|
||||
return 'xml';
|
||||
case 'text/json':
|
||||
return 'json';
|
||||
case 'text/plain':
|
||||
return 'json';
|
||||
default:
|
||||
return $this->error("Unsupported Content-Type: {$matches['type']}");
|
||||
}
|
||||
}
|
||||
|
||||
/***************************************************************************
|
||||
* RESOLVE FUNCTIONS
|
||||
* Given parsed tag data get OEmbed data
|
||||
**************************************************************************/
|
||||
|
||||
/*
|
||||
* Given parsed tag information, return OEmbed data
|
||||
*
|
||||
* $tag: Parsed tag information, as from parseTag()
|
||||
*
|
||||
* returns: false on error or array of OEmbed data
|
||||
* oembed: array of OEmbed data as returned from provider
|
||||
* query_url: URL used to get the OEmbed data
|
||||
* target_url: URL to which the OEmbed data refers
|
||||
*/
|
||||
function resolve($tag){
|
||||
|
||||
// try to resolve using cache
|
||||
if($data = $this->resolveCache($tag)) return $data;
|
||||
|
||||
// try to resolve directly
|
||||
if(array_key_exists('direct', $tag['params']['plugin'])){
|
||||
if($this->getConf('enable_direct_link')){
|
||||
return $this->resolveDirect($tag);
|
||||
}
|
||||
}
|
||||
|
||||
if($this->getConf('resolution_priority') == 'link discovery'){
|
||||
// try link discovery
|
||||
if($this->getConf('enable_link_discovery')){
|
||||
if($data = $this->resolveDiscovery($tag)) return $data;
|
||||
}
|
||||
|
||||
// try local provider list
|
||||
if($this->getConf('enable_provider_list')){
|
||||
if($data = $this->resolveProviderList($tag)) return $data;
|
||||
}
|
||||
}
|
||||
else if($this->getConf('resolution_priority') == 'provider list'){
|
||||
// try local provider list
|
||||
if($this->getConf('enable_provider_list')){
|
||||
if($data = $this->resolveProviderList($tag)) return $data;
|
||||
}
|
||||
|
||||
// try link discovery
|
||||
if($this->getConf('enable_link_discovery')){
|
||||
if($data = $this->resolveDiscovery($tag)) return $data;
|
||||
}
|
||||
}
|
||||
return $this->error("All resolution methods failed");
|
||||
}
|
||||
|
||||
/*
|
||||
* Analogous to resolve(), using the cache for resolution
|
||||
*/
|
||||
function resolveCache($tag){
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
* Analogous to resolve(), using a directly entered API endpoint for
|
||||
* resolution
|
||||
*/
|
||||
function resolveDirect($tag){
|
||||
$query_url = $this->buildURL($tag['url'], $tag['params']['provider']);
|
||||
if(!$response = $this->fetch($query_url)) return false;
|
||||
if(!$oembed = $this->parseResponse($response)) return false;
|
||||
|
||||
return array('oembed' => $oembed,
|
||||
'query_url' => $query_url,
|
||||
'target_url' => $tag['params']['provider']['url']);
|
||||
}
|
||||
|
||||
/*
|
||||
* Analogous to resolve(), using link discovery for resolution
|
||||
*/
|
||||
function resolveDiscovery($tag){
|
||||
|
||||
if(!$response = $this->fetch($tag['url'])) return false;
|
||||
if(!$link_url = $this->getOEmbedLink($response['body'])) return false;
|
||||
|
||||
$query_url = $this->buildURL($link_url, $tag['params']['provider']);
|
||||
|
||||
if(!$response = $this->fetch($query_url)) return false;
|
||||
if(!$oembed = $this->parseResponse($response)) return false;
|
||||
|
||||
|
||||
|
||||
return array('oembed' => $oembed,
|
||||
'query_url' => $query_url,
|
||||
'target_url' => $tag['url']);
|
||||
}
|
||||
|
||||
/*
|
||||
* Analogous to resolve(), using the local provider list for resolution
|
||||
*/
|
||||
function resolveProviderList($tag){
|
||||
if(!$api = $this->getProviderAPI($tag['url'])) return false;
|
||||
|
||||
$api = str_replace("{format}", $this->getConf('format_preference'), $api);
|
||||
$params = array_merge($tag['params']['provider'], array('url' => $tag['url']));
|
||||
$query_url = $this->buildURL($api, $params);
|
||||
|
||||
if(!$response = $this->fetch($query_url)) return false;
|
||||
if(!$oembed = $this->parseResponse($response)) return false;
|
||||
|
||||
return array('oembed' => $oembed,
|
||||
'query_url' => $query_url,
|
||||
'target_url' => $tag['url']);
|
||||
}
|
||||
|
||||
/***************************************************************************
|
||||
* RENDER FUNCTIONS
|
||||
* Convert OEmbed data to a presentable form
|
||||
**************************************************************************/
|
||||
|
||||
/*
|
||||
* Given OEmbed data as returned by resolve(), produces a valid XHTML
|
||||
* representation
|
||||
*
|
||||
* $data: OEmbed data as returned by resolve()
|
||||
*
|
||||
* returns: XHTML representation of OEmbed data
|
||||
*/
|
||||
function renderXHTML($data){
|
||||
$content = '';
|
||||
|
||||
if(!$data['oembed_data']){
|
||||
$content .= "OEmbed Error";
|
||||
$content .= "<ul>";
|
||||
foreach($data['errors'] as $error){
|
||||
$content .= "<li>".$error."</li>";
|
||||
}
|
||||
$content .= "</ul>";
|
||||
|
||||
return $content;
|
||||
}
|
||||
|
||||
$oembed = $this->sanitizeOEmbed($data['oembed_data']['oembed']);
|
||||
|
||||
if(array_key_exists('thumbnail', $data['tag']['params']['plugin'])){
|
||||
if($oembed['thumbnail_url']){
|
||||
$img = '<img src="'.$oembed['thumbnail_url'].'" alt="'.$oembed['title'].'" title="'.$oembed['title'].'" height="'.$oembed['thumbnail_height'].'px" width="'.$oembed['thumbnail_width'].'px"/>';
|
||||
$content = '<a href="'.$data['oembed_data']['target_url'].'">'.$img.'</a>';
|
||||
}
|
||||
else{
|
||||
$content = $this->renderXHTMLLink($data);
|
||||
}
|
||||
}
|
||||
else{
|
||||
switch($oembed['type']){
|
||||
case 'photo':
|
||||
if($this->getConf('fullwidth_images')){
|
||||
$content = '<img src="'.$oembed['url'].'" alt="'.$oembed['title'].'" title="'.$oembed['title'].'" width=100% />';
|
||||
} else {
|
||||
$content = '<img src="'.$oembed['url'].'" alt="'.$oembed['title'].'" title="'.$oembed['title'].'" height="'.$oembed['height'].'px" width="'.$oembed['width'].'px"/>';
|
||||
}
|
||||
break;
|
||||
case 'video':
|
||||
$content = $oembed['html'];
|
||||
break;
|
||||
case 'link':
|
||||
$content = $this->renderXHTMLLink($data);
|
||||
break;
|
||||
case 'rich':
|
||||
$content = $oembed['html'];
|
||||
break;
|
||||
default:
|
||||
$content = "OEmbed Error <ul><li>Unsupported media type: {$oembed['type']}</li></ul>";
|
||||
}
|
||||
}
|
||||
|
||||
return $content;
|
||||
}
|
||||
|
||||
/*
|
||||
* Given OEmbed data as returned by resolve(), produces a valid XHTML
|
||||
* representation as a simple link
|
||||
*
|
||||
* $data: OEmbed data as returned by resolve()
|
||||
*
|
||||
* returns: XHTML representation of OEmbed data as a simple link
|
||||
*/
|
||||
function renderXHTMLLink($data){
|
||||
$text .= ($data['oembed_data']['oembed']['provider_name'] != null) ? $data['oembed_data']['oembed']['provider_name'].': ' : '';
|
||||
$text .= $data['oembed_data']['oembed']['title'];
|
||||
$text .= ($data['oembed_data']['oembed']['author_name'] != null) ? ' – '.$data['oembed_data']['oembed']['author_name'] : '';
|
||||
return '<a class="urlextern" href="'.$data['oembed_data']['target_url'].'">'.$text.'</a>';
|
||||
}
|
||||
|
||||
/***************************************************************************
|
||||
* UTILITY FUNCTIONS
|
||||
* Provides shared functionality
|
||||
**************************************************************************/
|
||||
|
||||
/*
|
||||
* Stores a message in the errors array and returns false
|
||||
*
|
||||
* $msg: message to store
|
||||
*
|
||||
* returns: false
|
||||
*/
|
||||
function error($msg){
|
||||
array_push($this->errors, $msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
* Performs an HTTP GET request on the given URL
|
||||
*
|
||||
* $url: URL to perform the request on
|
||||
*
|
||||
* returns: false on error or array representing the HTTP response
|
||||
* status: numerical HTTP status code
|
||||
* headers: array of HTTP headers
|
||||
* name => value
|
||||
* body: HTTP response body
|
||||
*/
|
||||
function fetch($url){
|
||||
$client = new DokuHTTPClient();
|
||||
if(!$client->sendRequest($url)){
|
||||
return $this->error("Error sending request to provider: {$url}");
|
||||
}
|
||||
|
||||
return array('status' => $client->status,
|
||||
'headers' => $client->resp_headers,
|
||||
'body' => $client->resp_body);
|
||||
}
|
||||
|
||||
/*
|
||||
* Given a base URL, create a new URL using the given parameters. Query
|
||||
* values are URL encoded.
|
||||
*
|
||||
* $base: base URL, any existing parameter values should be URL encoded.
|
||||
* $params: array of parameters to add to URL
|
||||
* name => value
|
||||
*
|
||||
* returns: the new URL
|
||||
*/
|
||||
function buildURL($base, $params){
|
||||
$url = $base;
|
||||
|
||||
$first = strpos($base,"?") === false ? true : false;
|
||||
foreach($params as $name => $value){
|
||||
if($first){ $url .= "?"; $first = false; }
|
||||
else { $url .= "&"; }
|
||||
|
||||
$url .= $name."=".rawurlencode($value);
|
||||
}
|
||||
|
||||
return $url;
|
||||
}
|
||||
|
||||
/*
|
||||
* Given raw HTML, tries to extract oembed discovery link
|
||||
*
|
||||
* Based on code by Keith Devens:
|
||||
* http://keithdevens.com/weblog/archive/2002/Jun/03/RSSAuto-DiscoveryPHP
|
||||
*
|
||||
* Parameters:
|
||||
* $html: raw HTML
|
||||
*
|
||||
* Returns: false on error or no link present or an OEmbed discovery link
|
||||
*/
|
||||
function getOEmbedLink($html){
|
||||
$ret_link = false;
|
||||
|
||||
if(!$html) return false;
|
||||
|
||||
// search through the HTML, save all <link> tags
|
||||
// and store each link's attributes in an associative array
|
||||
preg_match_all('/<link\s+(.*?)\s*\/?>/si', $html, $matches);
|
||||
$links = $matches[1];
|
||||
$final_links = array();
|
||||
$link_count = count($links);
|
||||
for($n=0; $n<$link_count; $n++){
|
||||
$attributes = preg_split('/\s+/s', $links[$n]);
|
||||
foreach($attributes as $attribute){
|
||||
$att = preg_split('/\s*=\s*/s', $attribute, 2);
|
||||
if(isset($att[1])){
|
||||
$att[1] = preg_replace('/([\'"]?)(.*)\1/', '$2', $att[1]);
|
||||
$final_link[strtolower($att[0])] = $att[1];
|
||||
}
|
||||
}
|
||||
$final_links[$n] = $final_link;
|
||||
}
|
||||
|
||||
// now figure out which one points to the OEmbed data
|
||||
for($n=0; $n<$link_count; $n++){
|
||||
if(strtolower($final_links[$n]['rel']) == 'alternate'){
|
||||
if(strtolower($final_links[$n]['type']) == 'application/json+oembed'){
|
||||
if($this->getConf('format_preference') == 'json'){
|
||||
return $final_links[$n]['href'];
|
||||
}
|
||||
else{
|
||||
$ret_link = $final_links[$n]['href'];
|
||||
}
|
||||
}
|
||||
|
||||
// application/xml+oembed only exists for compatability not in spec
|
||||
if(strtolower($final_links[$n]['type']) == 'text/xml+oembed' or
|
||||
strtolower($final_links[$n]['type']) == 'application/xml+oembed'){
|
||||
if($this->getConf('format_preference') == 'xml'){
|
||||
return $final_links[$n]['href'];
|
||||
}
|
||||
else{
|
||||
$ret_link = $final_links[$n]['href'];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $ret_link;
|
||||
}
|
||||
|
||||
/*
|
||||
* Given a URL, finds a OEmbed provider API endpoint which can be used with
|
||||
* it from the local provider list.
|
||||
*
|
||||
* $url: URL to search a provider for
|
||||
*
|
||||
* Returns: false on error or no provider find or the API endpoint of an
|
||||
* appropriate provider
|
||||
*/
|
||||
function getProviderAPI($url){
|
||||
$providers_path = OEMBED_BASE.'providers.xml';
|
||||
if(!$providers = simplexml_load_file($providers_path)) return false;
|
||||
|
||||
foreach($providers->provider as $provider){
|
||||
foreach($provider->scheme as $scheme){
|
||||
$regex = "@^".str_replace("@","\@",$scheme)."$@i";
|
||||
if(preg_match($regex, trim($url))){
|
||||
$attrs = $provider->attributes();
|
||||
if(($api = $attrs['api']) != null){
|
||||
return $api;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
* Runs htmlspecialchars() on values in OEmbed data EXCEPT for html values
|
||||
*
|
||||
* $oembed: array of OEmbed data from parseResponse()
|
||||
*
|
||||
* Returns: identical array to $oembed in which all values except for html
|
||||
* are run through htmlspecialchars()
|
||||
*/
|
||||
function sanitizeOEmbed($oembed){
|
||||
$retarray = array();
|
||||
|
||||
foreach($oembed as $key => $value){
|
||||
if($key == 'html'){
|
||||
$retarray[$key] = $value;
|
||||
}
|
||||
else{
|
||||
$retarray[$key] = htmlspecialchars($value);
|
||||
}
|
||||
}
|
||||
|
||||
return $retarray;
|
||||
}
|
||||
|
||||
/***************************************************************************
|
||||
* DEBUG FUNCTIONS
|
||||
* For testing and devlopment, not regularly used
|
||||
**************************************************************************/
|
||||
|
||||
function _log($msg){
|
||||
$fh = fopen(OEMBED_BASE."oembed.log",'a');
|
||||
$curtime = date('Y-m-d H:i:s');
|
||||
fwrite($fh, "[{$curtime}] {$msg}\n");
|
||||
fclose($fh);
|
||||
}
|
||||
|
||||
function _logParsedTag($parsed_tag){
|
||||
$this->_log("Parsed Tag");
|
||||
$this->_log(" URL: {$parsed_tag['url']}");
|
||||
$this->_log(" Provider Params:");
|
||||
foreach($parsed_tag['params']['provider'] as $key => $value){
|
||||
$this->_log(" {$key} => {$value}");
|
||||
}
|
||||
$this->_log(" Plugin Params:");
|
||||
foreach($parsed_tag['params']['plugin'] as $key => $value){
|
||||
$this->_log(" {$key} => {$value}");
|
||||
}
|
||||
}
|
||||
|
||||
function _logOEmbedData($oembed){
|
||||
$this->_log("OEmbed Data:");
|
||||
$this->_log(" target_url: {$oembed['target_url']}");
|
||||
$this->_log(" query_url: {$oembed['query_url']}");
|
||||
$this->_log(" Response:");
|
||||
foreach($oembed['oembed'] as $name => $value){
|
||||
$this->_log(" {$name}: {$value}");
|
||||
}
|
||||
}
|
||||
|
||||
function _logErrors($errors){
|
||||
$this->_log("Errors:");
|
||||
foreach($errors as $error){
|
||||
$this->_log(" {$error}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user