--- /dev/null
+{% extends "base.htm" %}
+{% block title %}Fork remote paste{% endblock %}
+
+{% block content %}
+ {% include 'new-fork-remote.htm' %}
+{% endblock %}
--- /dev/null
+<form method="post" action="/fork-remote" enctype="multipart/form-data" class="well form-inline">
+ <p>
+ <strong>Copy a paste from a remote server:</strong>
+ Just paste the website or git clone URL.
+ </p>
+
+ <button type="submit" class="btn btn-primary" style="float: right">
+ <i class="icon-share icon-white"></i>Fork remote paste
+ </button>
+ <label for="remote-url">Remote paste URL</label>
+ <input type="text" name="remote_url" id="remote-url" value="{{remote_url}}" class="input-xlarge"/>
+</form>
</div>
</form>
+
+{% include 'new-fork-remote.htm' %}
+
<script type="application/javascript">
$(document).ready(function() {
initEdit();
--- /dev/null
+<?php
+namespace phorkie;
+
+class ForkRemote
+{
+ protected $url;
+
+ public function __construct($url)
+ {
+ $this->url = $url;
+ }
+
+ public function parse()
+ {
+ $scheme = parse_url($this->url, PHP_URL_SCHEME);
+ switch ($scheme) {
+ case 'git':
+ //clearly a git url
+ $this->gitUrl = $this->url;
+ return true;
+
+ case 'ssh':
+ //FIXME: maybe loosen this when we know how to skip the
+ //"do you trust this server" question of ssh
+ $this->error = 'ssh:// URLs are not supported';
+ return false;
+
+ case 'http':
+ case 'https':
+ return $this->extractUrlsFromHtml($this->url);
+ }
+
+ $this->error = 'Unknown URLs scheme: ' . $scheme;
+ return false;
+ }
+
+ protected function extractUrlsFromHtml($url)
+ {
+ }
+}
+
+?>
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 ^new$ /new.php
RewriteRule ^list$ /list.php
--- /dev/null
+<?php
+namespace phorkie;
+/**
+ * Fork a remote repository.
+ * Displays a URL selection form when multiple git urls have been found
+ */
+require_once 'www-header.php';
+
+if (isset($_POST['remote_url'])) {
+ $fr = new ForkRemote($_POST['remote_url']);
+ $fr->parse();
+ if ($fr->hasUniqueGitUrl()) {
+ //FIXME: fork
+ }
+ //FIXME: display error or selection list
+}
+
+render(
+ 'fork-remote',
+ array(
+ 'remote_url' => isset($_POST['remote_url']) ? $_POST['remote_url'] : ''
+ )
+);
+?>