- add new files
- delete existing files
- replace file with upload
-- embedding of pastes in your blog
+- embedding of pastes in your blog via oEmbed
- multiple files in one paste
- option to edit single files in a multi-file paste
- syntax highlighting with GeSHi
{% block meta %}
<link rel="meta" title="DOAP" type="application/rdf+xml" href="{{repo.getLink('doap')}}"/>
+ <link rel="alternate" title="oEmbed" type="application/json+oembed" href="{{repo.getLink('oembed-json', null, true)}}" />
+ <link rel="alternate" title="oEmbed" type="application/xml+oembed" href="{{repo.getLink('oembed-xml', null, true)}}" />
{% if repo.getCloneURL(true) %}
<link rel="vcs-git" href="{{repo.getCloneURL(true)}}" title="{{repo.getTitle}}"/>
{% endif %}
--- /dev/null
+<!-- embedding all files of {{repo.getLink('display', null, true)}} -->
+<link rel="stylesheet" href="{{htmlhelper.fullUrl('css/embed.css')}}"/>
+<div class="phork" id="{{repo.id}}">
+{% for file in repo.getFiles %}
+ {% include 'embed-part-file.htm' %}
+{% endfor %}
+</div>
$link = $this->id . '/delete/confirm';
} else if ($type == 'embed') {
$link = $this->id . '/embed';
+ } else if ($type == 'oembed-json') {
+ $link = 'oembed.php?format=json&url='
+ . urlencode($this->getLink('display', null, true));
+ } else if ($type == 'oembed-xml') {
+ $link = 'oembed.php?format=xml&url='
+ . urlencode($this->getLink('display', null, true));
} else if ($type == 'remotefork') {
return 'web+fork:' . $this->getLink('display', null, true);
} else if ($type == 'revision') {
--- /dev/null
+<?php
+namespace phorkie;
+/**
+ * Embed a paste via oEmbed
+ *
+ * @link http://www.oembed.com/
+ */
+$reqWritePermissions = false;
+require_once 'www-header.php';
+
+if (!isset($_GET['url'])) {
+ header('HTTP/1.0 400 Bad Request');
+ echo "url parameter missing\n";
+ exit(1);
+}
+
+if (!isset($_GET['format'])) {
+ $format = 'json';
+} else if ($_GET['format'] != 'json' && $_GET['format'] != 'xml') {
+ header('HTTP/1.0 400 Bad Request');
+ echo "Invalid format parameter\n";
+ exit(1);
+} else {
+ $format = $_GET['format'];
+}
+
+if (!isset($_GET['maxwidth'])) {
+ $maxWidth = 900;
+} else {
+ $maxWidth = (int) $_GET['maxwidth'];
+ if ($maxWidth <= 100) {
+ header('HTTP/1.0 400 Bad Request');
+ echo "maxwidth parameter too small\n";
+ exit(1);
+ }
+}
+
+if (!isset($_GET['maxheight'])) {
+ $maxHeight = 900;
+} else {
+ $maxHeight = (int) $_GET['maxheight'];
+ if ($maxHeight <= 100) {
+ header('HTTP/1.0 400 Bad Request');
+ echo "maxheight parameter too small\n";
+ exit(1);
+ }
+}
+
+
+$parts = explode('/', $_GET['url']);
+$id = end($parts);
+
+$repo = new Repository();
+$repo->loadById($id);
+
+if ($format == 'json') {
+ $data = new \stdClass();
+} else {
+ $data = new \SimpleXMLElement(
+ '<?xml version="1.0" encoding="utf-8" standalone="yes"?>'
+ . '<oembed/>'
+ );
+}
+$data->type = 'rich';
+$data->version = '1.0';
+
+$data->provider_name = 'phorkie';
+$data->provider_url = Tools::fullUrl();
+
+$data->title = $repo->getTitle();
+$author = $repo->getOwner();
+$data->author_name = $author['name'];
+$data->cache_age = 86400;
+
+$data->width = $maxWidth;
+$data->height = $maxHeight;
+
+$data->html = render('oembed', array('repo' => $repo), true);
+
+if ($format == 'json') {
+ header('Content-type: application/json');
+ echo json_encode($data) . "\n";
+} else {
+ header('Content-type: text/xml');
+ echo $data->asXML();;
+}
+?>
require __DIR__ . '/www-security.php';
}
-function render($tplname, $vars = array())
+function render($tplname, $vars = array(), $return = false)
{
$vars['baseurl'] = '/';
if (!empty($GLOBALS['phorkie']['cfg']['baseurl'])) {
$vars['suggestSetupCheck'] = $GLOBALS['phorkie']['suggestSetupCheck'];
$template = $GLOBALS['twig']->loadTemplate($tplname . '.htm');
- echo $template->render($vars);
+
+ if ($return) {
+ return $template->render($vars);
+ } else {
+ echo $template->render($vars);
+ }
}
+
function redirect($target)
{
header('Location: ' . $target);