</form>
</div>
</div>
-
-{% if repo.getCloneURL(true) or repo.getCloneURL(false) %}
-<div class="urlinfo well well-small">
- {% if repo.getCloneURL(true) %}
- <div class="row-fluid">
- <div class="span3">Public clone URL</div>
- <div class="span9">
- <a href="{{repo.getCloneURL(true)}}">{{repo.getCloneURL(true)}}</a>
- </div>
- </div>
- {% endif %}
- {% if repo.getCloneURL(false) %}
- <div class="row-fluid">
- <div class="span3">Private clone URL</div>
- <div class="span9">
- <a href="{{repo.getCloneURL(false)}}">{{repo.getCloneURL(false)}}</a>
- </div>
- </div>
- {% endif %}
-</div>
-{% endif %}
--- /dev/null
+<label id="url-embed" for="url-embed-input"><b>Embed</b> HTML code</label>
+<input id="url-embed-input" type="text" class="fullwidthtext" value='<script src="{{repo.getLink('embed', null, true)}}" type="text/javascript"></script>'/>
+
+{% if repo.getCloneURL(true) %}
+<label id="url-public" for="url-public-input"><b>Public</b> clone URL</label>
+<input id="url-public-input" type="text" class="fullwidthtext" value="{{repo.getCloneURL(true)}}"/>
+{% endif %}
+
+{% if repo.getCloneURL(false) %}
+<label id="url-private" for="url-private-input"><b>Private</b> clone URL</label>
+<input id="url-private-input" type="text" class="fullwidthtext" value="{{repo.getCloneURL(false)}}"/>
+{% endif %}
{% block sidebar %}
{% include 'display-sidebar-owner.htm' %}
+ {% include 'display-sidebar-urls.htm' %}
{% include 'display-sidebar-fork.htm' %}
{% include 'display-sidebar-history.htm' %}
{% endblock %}
--- /dev/null
+/* embedding {{file.getFilename()}} of {{repo.getLink('display', null, true)}} */
+document.write('<link rel="stylesheet" href="{{htmlhelper.fullUrl('css/embed.css')}}"/>');
+document.write(
+ '<div class="phork" id="{{repo.id}}">'
+ + {% filter json_encode(constant('JSON_UNESCAPED_SLASHES'))|raw -%}{% include 'embed-part-file.htm' %}{%- endfilter %}
+ + '</div>'
+);
--- /dev/null
+<div class="phork-file">
+ <div class="phork-content">
+ {{file.getRenderedContent(toolres)|raw}}
+ </div>
+ <div class="phork-meta">
+ <a href="{{file.getLink('raw', null, true)}}" style="float: right">view raw source</a>
+ <a href="{{file.getLink('display', null, true)}}">{{file.getFilename()}}</a>
+ </div>
+</div>
--- /dev/null
+/* embedding all files of {{repo.getLink('display', null, true)}} */
+document.write('<link rel="stylesheet" href="{{htmlhelper.fullUrl('css/embed.css')}}"/>');
+document.write(
+ '<div class="phork" id="{{repo.id}}">'
+{% for file in repo.getFiles %}
+ + {% filter json_encode(constant('JSON_UNESCAPED_SLASHES'))|raw -%}{% include 'embed-part-file.htm' %}{%- endfilter %}
+{% endfor %}
+ + '</div>'
+);
* Get a link to the file
*
* @param string $type Link type. Supported are:
+ * - "display"
* - "raw"
* - "tool"
* @param string $option Additional option, e.g. tool name
+ * @param boolean $full Return full URL or normal relative
*
* @return string
*/
- public function getLink($type, $option = null)
+ public function getLink($type, $option = null, $full = false)
{
if ($type == 'raw') {
if ($this->repo->hash === null) {
- return $this->repo->id . '/raw/' . $this->getFilename();
+ $link = $this->repo->id . '/raw/' . $this->getFilename();
} else {
- return $this->repo->id . '/rev-raw/' . $this->repo->hash
+ $link = $this->repo->id . '/rev-raw/' . $this->repo->hash
. '/' . $this->getFilename();
}
} else if ($type == 'tool') {
- return $this->repo->id
+ $link = $this->repo->id
. '/tool/' . $option
. '/' . $this->getFilename();
+ } else if ($type == 'display') {
+ $link = $this->repo->id . '#' . $this->getFilename();
+ } else {
+ throw new Exception('Unknown type');
}
- throw new Exception('Unknown type');
+
+ if ($full) {
+ $link = Tools::fullUrl($link);
+ }
+ return $link;
}
/**
}
$geshi = new \geshi($file->getContent(), $this->getType($file));
$geshi->enable_line_numbers(GESHI_NORMAL_LINE_NUMBERS);
- $geshi->set_header_type(GESHI_HEADER_DIV);
+ $geshi->set_header_type(GESHI_HEADER_PRE_TABLE);
+ $geshi->enable_classes();
+ $geshi->set_line_style('color: #DDD;');
if ($res !== null) {
$geshi->highlight_lines_extra(array_keys($res->annotations));
$geshi->set_highlight_lines_extra_style('background-color: #F2DEDE');
}
- return '<div class="code">'
+ return '<style type="text/css">'
+ . $geshi->get_stylesheet() . '</style>'
+ . '<div class="code">'
. str_replace(' ', ' ', $geshi->parse_code())
. '</div>';
}
* - "delete"
* - "delete-confirm"
* - "display"
+ * - "embed"
* - "fork"
* - "revision"
* @param string $option Additional link option, e.g. revision number
$link = $this->id . '/delete';
} else if ($type == 'delete-confirm') {
$link = $this->id . '/delete/confirm';
+ } else if ($type == 'embed') {
+ $link = $this->id . '/embed';
} else if ($type == 'remotefork') {
return 'web+fork:' . $this->getLink('display', null, true);
} else if ($type == 'revision') {
RewriteRule ^([0-9]+)/doap$ doap.php?id=$1
RewriteRule ^([0-9]+)/edit$ edit.php?id=$1
RewriteRule ^([0-9]+)/edit/(.+)$ edit.php?id=$1&file=$2
+RewriteRule ^([0-9]+)/embed$ embed.php?id=$1
+RewriteRule ^([0-9]+)/embed/(.+)$ embed-file.php?id=$1&file=$2
RewriteRule ^([0-9]+)/fork$ fork.php?id=$1
RewriteRule ^([0-9]+)/linkback$ linkback.php?id=$1
RewriteRule ^([0-9]+)/raw/(.+)$ raw.php?id=$1&file=$2
--- /dev/null
+.phork-file {
+ border: 1px solid #DDD;
+ border-bottom: 1px solid #CCC;
+ border-radius: 3px;
+ padding: 0px;
+ background-color: white;
+ margin-bottom: 2ex;
+ margin-top: 2ex;
+}
+.phork-content {
+ padding: 0.6ex;
+}
+.phork-file > .code {
+ overflow-x: auto;
+}
+.phork-file .code pre {
+ border: none;
+ background-color: inherit;
+ word-break: normal;
+ word-wrap: normal;
+ white-space: pre;
+ color: black;
+ font: normal normal 1em/1.2em monospace;
+ padding: 0px;
+ margin: 0px;
+}
+.phork-file .code .ln pre {
+ margin-right: 1ex;
+ color: #DDD;
+}
+.phork-meta {
+ background-color: #EEE;
+ font-size: 75%;
+ padding: 0.5ex 1ex;
+ margin: none;
+}
+.phork-meta a {
+ font-family: sans-serif;
+ text-decoration: none;
+ color: #888;
+ font-weight: bold;
+}
\ No newline at end of file
.file .image {
margin-bottom: 2ex;
}
+.file > .document {
+ margin-left: 1em;
+}
+
+.code pre {
+ border: none;
+ background-color: inherit;
+ word-break: normal;
+ word-wrap: normal;
+ white-space: pre;
+ color: black;
+ font: normal normal 1em/1.2em monospace;
+ padding: 0px;
+ margin: 0px;
+ margin-bottom: 2ex;
+}
+.code {
+ overflow-x: auto;
+}
+.code .ln pre {
+ margin-right: 1ex;
+ color: #DDD;
+}
div.annotations div.alert {
margin-bottom: 1ex;
margin-left: 8em;
}
+input.fullwidthtext {
+ width: 100%;
+ box-sizing: border-box;
+ height: auto;
+}
+
.btn [class^="icon-"], .btn [class*=" icon-"] {
line-height: 1.1em;
}
--- /dev/null
+<?php
+namespace phorkie;
+/**
+ * Embed a file of a paste into a HTML site.
+ * We deliver javascript for that.
+ */
+$reqWritePermissions = false;
+require_once 'www-header.php';
+
+$repo = new Repository();
+$repo->loadFromRequest();
+
+if (!isset($_GET['file']) || $_GET['file'] == '') {
+ throw new Exception_Input('File name missing');
+}
+
+$file = $repo->getFileByName($_GET['file']);
+header('Content-Type: text/javascript');
+header('Expires: ' . date('r', time() + 3600));
+render(
+ 'embed-file',
+ array(
+ 'repo' => $repo,
+ 'file' => $file,
+ )
+);
+?>
--- /dev/null
+<?php
+namespace phorkie;
+/**
+ * Embed a file of a paste into a HTML site.
+ * We deliver javascript for that.
+ */
+$reqWritePermissions = false;
+require_once 'www-header.php';
+
+$repo = new Repository();
+$repo->loadFromRequest();
+
+header('Content-Type: text/javascript');
+header('Expires: ' . date('r', time() + 3600));
+render(
+ 'embed',
+ array(
+ 'repo' => $repo,
+ )
+);
+?>
var jt = jQuery(elem);
jt.children('i').toggleClass('icon-chevron-down')
.toggleClass('icon-chevron-up');
- jt.parents('.row-fluid').children('.additional').toggle(time);
+ //jt.parents('.row-fluid').children('.additional').toggle(time);
+ jt.parents('.row-fluid').children('.additional').animate(time);
}