diff options
| author | Christian Weiske <cweiske@cweiske.de> | 2012-09-18 21:31:49 +0200 |
|---|---|---|
| committer | Christian Weiske <cweiske@cweiske.de> | 2012-09-18 21:31:49 +0200 |
| commit | 63575a005e8e2386abb24e97791e18d61e6350fe (patch) | |
| tree | 7dcf91e9e8cf5c75602b6ea9c6d1a64af129d800 | |
| parent | dca6d8d7b6bb61f303c17905dde4ecbde7ff1da5 (diff) | |
| download | phorkie-63575a005e8e2386abb24e97791e18d61e6350fe.tar.gz phorkie-63575a005e8e2386abb24e97791e18d61e6350fe.zip | |
first work on remote forking
| -rw-r--r-- | data/templates/fork-remote.htm | 6 | ||||
| -rw-r--r-- | data/templates/new-fork-remote.htm | 12 | ||||
| -rw-r--r-- | data/templates/new.htm | 5 | ||||
| -rw-r--r-- | src/phorkie/ForkRemote.php | 42 | ||||
| -rw-r--r-- | www/.htaccess | 1 | ||||
| -rw-r--r-- | www/fork-remote.php | 24 |
6 files changed, 89 insertions, 1 deletions
diff --git a/data/templates/fork-remote.htm b/data/templates/fork-remote.htm new file mode 100644 index 0000000..f599ec6 --- /dev/null +++ b/data/templates/fork-remote.htm @@ -0,0 +1,6 @@ +{% extends "base.htm" %} +{% block title %}Fork remote paste{% endblock %} + +{% block content %} + {% include 'new-fork-remote.htm' %} +{% endblock %} diff --git a/data/templates/new-fork-remote.htm b/data/templates/new-fork-remote.htm new file mode 100644 index 0000000..02a94e2 --- /dev/null +++ b/data/templates/new-fork-remote.htm @@ -0,0 +1,12 @@ +<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> diff --git a/data/templates/new.htm b/data/templates/new.htm index 5b75bba..f846fe5 100644 --- a/data/templates/new.htm +++ b/data/templates/new.htm @@ -20,6 +20,9 @@ </div> </form> + +{% include 'new-fork-remote.htm' %} + <script type="application/javascript"> $(document).ready(function() { initEdit(); @@ -37,4 +40,4 @@ $(document).ready(function() { {% endfor %} </ul> {% endif %} -{% endblock %}
\ No newline at end of file +{% endblock %} diff --git a/src/phorkie/ForkRemote.php b/src/phorkie/ForkRemote.php new file mode 100644 index 0000000..f3639b2 --- /dev/null +++ b/src/phorkie/ForkRemote.php @@ -0,0 +1,42 @@ +<?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) + { + } +} + +?> diff --git a/www/.htaccess b/www/.htaccess index c379b23..efb03a9 100644 --- a/www/.htaccess +++ b/www/.htaccess @@ -13,6 +13,7 @@ RewriteRule ^([0-9]+)/rev/(.+)$ /revision.php?id=$1&rev=$2 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 diff --git a/www/fork-remote.php b/www/fork-remote.php new file mode 100644 index 0000000..dd58165 --- /dev/null +++ b/www/fork-remote.php @@ -0,0 +1,24 @@ +<?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'] : '' + ) +); +?> |
