aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.rst6
-rw-r--r--data/templates/display-head.htm12
-rw-r--r--data/templates/help.htm49
-rw-r--r--src/phorkie/HtmlHelper.php5
-rw-r--r--src/phorkie/Repository.php2
-rw-r--r--www/.htaccess1
-rw-r--r--www/fork-remote.php10
-rw-r--r--www/help.php15
8 files changed, 96 insertions, 4 deletions
diff --git a/README.rst b/README.rst
index 7df1579..1270c30 100644
--- a/README.rst
+++ b/README.rst
@@ -288,6 +288,10 @@ URLs
Search for term, with optional page
``/list(/[0-9])?``
List all pastes, with optional page
+``/fork-remote``
+ Fork a remote URL
+``/help``
+ Show help page
``/new``
Shows form for new paste
``/login``
@@ -329,6 +333,8 @@ If you use nginx, place the following lines into your ``server`` block:
rewrite ^/([0-9]+)/rev-raw/(.+)$ /raw.php?id=$1&rev=$2&file=$3;
rewrite ^/([0-9]+)/tool/([^/]+)/(.+)$ /tool.php?id=$1&tool=$2&file=$3;
+ rewrite ^/fork-remote$ /fork-remote.php;
+ rewrite ^/help$ /help.php;
rewrite ^/new$ /new.php;
rewrite ^/feed/new$ /feed-new.php;
rewrite ^/feed/updated$ /feed-updated.php;
diff --git a/data/templates/display-head.htm b/data/templates/display-head.htm
index 78c32a5..ba699bf 100644
--- a/data/templates/display-head.htm
+++ b/data/templates/display-head.htm
@@ -5,7 +5,17 @@
</div>
<div class="span2 pull-right">
<form method="post" action="{{repo.getLink('fork')}}">
- <button type="submit" class="btn pull-right"><i class="icon-share"></i> fork</button>
+ <div class="btn-group pull-right">
+ <button type="submit" class="btn"><i class="icon-share"></i> fork</button>
+ <button class="btn dropdown-toggle" data-toggle="dropdown">
+ <span class="caret"></span>
+ </button>
+ <ul class="dropdown-menu">
+ <li><a href="{{repo.getLink('remotefork')}}"><i class="icon-share"></i> Fork to remote system</a></li>
+ <li class="divider"></li>
+ <li><a href="help#remote-forking"><i class="icon-question-sign"></i> Help on remote forking</a></li>
+ </ul>
+ </div>
</form>
</div>
</div>
diff --git a/data/templates/help.htm b/data/templates/help.htm
new file mode 100644
index 0000000..555a738
--- /dev/null
+++ b/data/templates/help.htm
@@ -0,0 +1,49 @@
+{% extends "base.htm" %}
+{% block title %}phorkie help{% endblock %}
+
+{% block content %}
+<h1>Help on phorkie</h1>
+
+<h2 id="remote-forking">Remote forking</h2>
+<script type="text/javascript">
+function registerHandler() {
+ navigator.registerProtocolHandler(
+ "web+fork",
+ "{{htmlhelper.fullUrl('fork-remote?remote_url=%s')}}",
+ "phorkie@"
+ + "{{htmlhelper.fullUrl()}}"
+ .replace(/https?:\/\//, '')
+ .replace(/\/$/, '')
+ );
+}
+</script>
+
+<div class="row-fluid">
+ <div class="span8">
+ <p>
+ Phorkie allows cloning/forking of pastes on other servers
+ - other phorkie instances, github gists or simply any remote
+ git repository.
+ </p>
+ <p>
+ You can go to <a href="fork-remote">fork-remote</a> and enter the
+ URL of the paste on the other server.
+ </p>
+ <p>
+ It's way easier to simply click a "fork" button that automatically
+ takes you to this phorkie's remote paste page, prefilled with
+ the correct git URL.
+ </p>
+ <p>
+ To make this work, click the register button on the right.
+ It will register a "protocol handler" for "web+fork:"-URLs,
+ making phorkie chime in whenever a <tt>web+fork</tt> URL is clicked.
+ </p>
+ </div>
+ <div class="span4">
+ <a href="#" onclick="registerHandler(); return false;" class="btn">
+ register web+fork protocol handler
+ </a>
+ </div>
+</div>
+{% endblock %}
diff --git a/src/phorkie/HtmlHelper.php b/src/phorkie/HtmlHelper.php
index 945c7ea..efde714 100644
--- a/src/phorkie/HtmlHelper.php
+++ b/src/phorkie/HtmlHelper.php
@@ -39,6 +39,11 @@ class HtmlHelper
}
return $html;
}
+
+ public function fullUrl($path = '')
+ {
+ return Tools::fullUrl($path);
+ }
}
?>
diff --git a/src/phorkie/Repository.php b/src/phorkie/Repository.php
index 2683ad0..9de2e1a 100644
--- a/src/phorkie/Repository.php
+++ b/src/phorkie/Repository.php
@@ -331,6 +331,8 @@ class Repository
$link = $this->id . '/delete';
} else if ($type == 'delete-confirm') {
$link = $this->id . '/delete/confirm';
+ } else if ($type == 'remotefork') {
+ return 'web+fork:' . $this->getLink('display', null, true);
} else if ($type == 'revision') {
$link = $this->id . '/rev/' . $option;
} else if ($type == 'linkback') {
diff --git a/www/.htaccess b/www/.htaccess
index 94a6979..bf8c582 100644
--- a/www/.htaccess
+++ b/www/.htaccess
@@ -18,6 +18,7 @@ RewriteRule ^([0-9]+)/rev-raw/(.+)/(.+)$ raw.php?id=$1&rev=$2&file=$3
RewriteRule ^([0-9]+)/tool/([^/]+)/(.+)$ tool.php?id=$1&tool=$2&file=$3
RewriteRule ^fork-remote$ fork-remote.php
+RewriteRule ^help$ help.php
RewriteRule ^new$ new.php
RewriteRule ^feed/new$ feed-new.php
diff --git a/www/fork-remote.php b/www/fork-remote.php
index 4f1b682..f41f981 100644
--- a/www/fork-remote.php
+++ b/www/fork-remote.php
@@ -8,8 +8,12 @@ require_once 'www-header.php';
$error = null;
$urls = null;
-if (isset($_POST['remote_url'])) {
- $fr = new ForkRemote($_POST['remote_url']);
+if (isset($_REQUEST['remote_url'])) {
+ if (substr($_REQUEST['remote_url'], 0, 9) == 'web+fork:') {
+ $_REQUEST['remote_url'] = substr($_REQUEST['remote_url'], 9);
+ }
+
+ $fr = new ForkRemote($_REQUEST['remote_url']);
if (false === $fr->parse()) {
//no url found
$error = $fr->error;
@@ -45,7 +49,7 @@ if (is_array($urls)) {
render(
'fork-remote',
array(
- 'remote_url' => isset($_POST['remote_url']) ? $_POST['remote_url'] : '',
+ 'remote_url' => isset($_REQUEST['remote_url']) ? $_REQUEST['remote_url'] : '',
'error' => $error,
'urls' => $urls,
'urlselsize' => $selsize,
diff --git a/www/help.php b/www/help.php
new file mode 100644
index 0000000..fe56c22
--- /dev/null
+++ b/www/help.php
@@ -0,0 +1,15 @@
+<?php
+namespace phorkie;
+/**
+ * Show help
+ */
+$reqWritePermissions = false;
+require_once 'www-header.php';
+
+render(
+ 'help',
+ array(
+ 'htmlhelper' => new HtmlHelper(),
+ )
+);
+?>