Look at ``config.default.php`` for values that you may adjust.
5. Set your web server's document root to ``/path/to/phorkie/www/``
+ Alternatively, you can add a symlink to the ``www`` folder into your
+ web server's existing document root tree (being careful to keep
+ main phorkie folder outside the document root for security purposes)
+ and ensure you set the ``baseurl`` config option appropriately. You
+ must also set the ``RewriteBase`` in the ``.htaccess`` file or adjust
+ the nginx configuration accordingly.
6. Open phorkie in your web browser
'gitdir' => __DIR__ . '/../repos/git/',
'workdir' => __DIR__ . '/../repos/work/',
'tpl' => __DIR__ . '/templates/',
+ 'baseurl' => '/',
'css' => '',
'title' => 'phorkie',
'topbar' => '',
<?php
+//$GLOBALS['phorkie']['cfg']['baseurl'] = '/';
//$GLOBALS['phorkie']['cfg']['gitdir'] = '/var/cache/git/paste/git/';
//$GLOBALS['phorkie']['cfg']['workdir'] = '/var/cache/git/paste/work/';
//$GLOBALS['phorkie']['cfg']['git']['public'] = 'git://bogo/git/paste/';
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html>
<html>
- <head>
+ <head>
+ <base href="{{baseurl}}" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
- <link rel="stylesheet" href="/css/bootstrap.min.css"/>
- <link rel="stylesheet" href="/css/font-awesome.css"/>
- <link rel="stylesheet" href="/css/phorkie.css"/>
+ <link rel="stylesheet" href="css/bootstrap.min.css"/>
+ <link rel="stylesheet" href="css/font-awesome.css"/>
+ <link rel="stylesheet" href="css/phorkie.css"/>
{% if css %}
<link rel="stylesheet" href="{{css}}"/>
{% endif %}
<title>{% block title %}{% endblock %} - {{title}}</title>
- <script src="/js/jquery.js"></script>
- <script src="/js/bootstrap.min.js"></script>
- <script src="/js/phorkie.js"></script>
+ <script src="js/jquery.js"></script>
+ <script src="js/bootstrap.min.js"></script>
+ <script src="js/phorkie.js"></script>
{% block meta %}{% endblock %}
</head>
<body>
<div class="container">
<ul class="nav">
<li>
- <a class="brand" href="/">{{title}}</a>
+ <a class="brand" href="{{baseurl}}">{{title}}</a>
</li>
<li>
- <a href="/new">New paste</a>
+ <a href="new">New paste</a>
</li>
<li>
- <a href="/list">List all</a>
+ <a href="list">List all</a>
</li>
{% if db.adapter %}
<li class="nav-collapse">
- <form class="span4 pull-right navbar-form" action="/search" method="get">
+ <form class="span4 pull-right navbar-form" action="search" method="get">
<input type="text" class="search-query" name="q" placeholder="Search" value="{{query}}"/>
</form>
</li>
<ul class="nav pull-right">
{% if identity %}
<li>
- <a href="/user">{{name}}</a>
+ <a href="user">{{name}}</a>
</li>
{% endif %}
{% if db.adapter %}
{% endif %}
{% if identity %}
<li>
- <a href="/login?logout">Logout</a>
+ <a href="login?logout">Logout</a>
</li>
{% else %}
<li>
- <a href="/login">Login</a>
+ <a href="login">Login</a>
</li>
{% endif %}
</ul>
<li class="row-fluid {% if commit.hash == repo.hash or (repo.hash == '' and loop.first) %}active{%endif%}">
{% spaceless %}
{% for dot in commit.getDots %}
- <img src="/phorkie/dot-{{dot}}.png" alt="" style="padding-left:1px" width="4" height="4"/>
+ <img src="phorkie/dot-{{dot}}.png" alt="" style="padding-left:1px" width="4" height="4"/>
{% endfor %}
{% endspaceless %}
<a class="hash" href="{{repo.getLink('revision', commit.hash)}}">{{commit.hash|slice(0, 6)}}</a>
<!DOCTYPE html>
<html>
- <head>
- <link rel="stylesheet" href="/css/phorkie.css" />
+ <head>
+ <base href="{{baseurl}}" />
+ <link rel="stylesheet" href="css/phorkie.css" />
<title>Error - phorkie</title>
<meta name="robots" content="noindex"/>
</head>
</p>
{% else %}
<p>
- We're sorry; but you have to <a href="/login">log in</a> to access this page.
+ We're sorry; but you have to <a href="login">log in</a> to access this page.
</p>
{% endif %}
{% endblock %}
-<form method="post" action="/fork-remote" enctype="multipart/form-data" class="well form-inline form-horizontal">
+<form method="post" action="fork-remote" enctype="multipart/form-data" class="well form-inline form-horizontal">
<input type="hidden" name="orig_url" value="{{remote_url}}" />
<div class="control-group">
<p>
-<form method="post" action="/fork-remote" enctype="multipart/form-data" class="well form-horizontal">
+<form method="post" action="fork-remote" enctype="multipart/form-data" class="well form-horizontal">
<p>
<strong>Copy a paste from a remote server:</strong>
Just paste the website or git clone URL.
<link rel="stylesheet" href="css/openid.css" />
-<form method="post" action="/login" id="openid_form">
+<form method="post" action="login" id="openid_form">
<fieldset>
<legend>Sign-in</legend>
<div id="openid_choice" style="display: block; ">
<p>Please choose your account provider</p>
<div id="openid_btns">
- <a title="Google" href="/login?openid_url=https://www.google.com/accounts/o8/id" class="google openid_large_btn"></a>
- <a title="Yahoo" href="/login?openid_url=http://yahoo.com/" class="yahoo openid_large_btn"></a>
+ <a title="Google" href="login?openid_url=https://www.google.com/accounts/o8/id" class="google openid_large_btn"></a>
+ <a title="Yahoo" href="login?openid_url=http://yahoo.com/" class="yahoo openid_large_btn"></a>
</div>
<div id="openid_input_area">
<p>or enter your OpenID URL.</p>
{% block content %}
<div class="content-padding-fix"></div>
-<form method="post" action="/new" enctype="multipart/form-data" class="form-horizontal">
+<form method="post" action="new" enctype="multipart/form-data" class="form-horizontal">
<div class="control-group">
<label class="control-label" for="description">Description</label>
<div class="controls">
{
if ($type == 'raw') {
if ($this->repo->hash === null) {
- return '/' . $this->repo->id . '/raw/' . $this->getFilename();
+ return $this->repo->id . '/raw/' . $this->getFilename();
} else {
- return '/' . $this->repo->id . '/rev-raw/' . $this->repo->hash
+ return $this->repo->id . '/rev-raw/' . $this->repo->hash
. '/' . $this->getFilename();
}
} else if ($type == 'tool') {
- return '/' . $this->repo->id
+ return $this->repo->id
. '/tool/' . $option
. '/' . $this->getFilename();
}
'currentPage' => $currentPage,
'urlVar' => 'page',
'append' => $append,
- 'path' => '/',
+ 'path' => '',
'fileName' => $filename,
'separator' => '###',
'spacesBeforeSeparator' => 0,
public function getIconUrl($email, $size = 32)
{
if ($email == 'anonymous@phorkie') {
- return '/phorkie/anonymous.png';
+ return 'phorkie/anonymous.png';
}
$s = new \Services_Libravatar();
$email,
array(
'size' => $size,
- 'default' => Tools::fullUrl('/phorkie/anonymous.png')
+ 'default' => Tools::fullUrl('phorkie/anonymous.png')
)
);
}
public function getLink($type, $option = null, $full = false)
{
if ($type == 'edit') {
- $link = '/' . $this->id . '/edit';
+ $link = $this->id . '/edit';
} else if ($type == 'display') {
- $link = '/' . $this->id;
+ $link = $this->id;
} else if ($type == 'fork') {
- $link = '/' . $this->id . '/fork';
+ $link = $this->id . '/fork';
} else if ($type == 'doap') {
- $link = '/' . $this->id . '/doap';
+ $link = $this->id . '/doap';
} else if ($type == 'delete') {
- $link = '/' . $this->id . '/delete';
+ $link = $this->id . '/delete';
} else if ($type == 'delete-confirm') {
- $link = '/' . $this->id . '/delete/confirm';
+ $link = $this->id . '/delete/confirm';
} else if ($type == 'revision') {
- $link = '/' . $this->id . '/rev/' . $option;
+ $link = $this->id . '/rev/' . $option;
} else {
throw new Exception('Unknown link type');
}
public function getLink($query)
{
- return '/search?q=' . urlencode($query);
+ return 'search?q=' . urlencode($query);
}
}
*
* @return string Full URL
*/
- public static function fullUrl($path)
+ public static function fullUrl($path = '')
{
if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS']) {
$prot = 'https';
} else {
$prot = 'http';
}
- return $prot . '://' . $_SERVER['HTTP_HOST'] . $path;
+ return $prot . '://' . $_SERVER['HTTP_HOST'] . $GLOBALS['phorkie']['cfg']['baseurl'] . $path;
}
/**
RewriteBase /
#RewriteCond %{REQUEST_FILENAME} -f
-RewriteRule ^([0-9]+)$ /display.php?id=$1
-RewriteRule ^([0-9]+)/delete$ /delete.php?id=$1
-RewriteRule ^([0-9]+)/delete/confirm$ /delete.php?id=$1&confirm=1
-RewriteRule ^([0-9]+)/doap$ /doap.php?id=$1
-RewriteRule ^([0-9]+)/edit$ /edit.php?id=$1
-RewriteRule ^([0-9]+)/fork$ /fork.php?id=$1
-RewriteRule ^([0-9]+)/raw/(.+)$ /raw.php?id=$1&file=$2
-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 ^([0-9]+)$ display.php?id=$1
+RewriteRule ^([0-9]+)/delete$ delete.php?id=$1
+RewriteRule ^([0-9]+)/delete/confirm$ delete.php?id=$1&confirm=1
+RewriteRule ^([0-9]+)/doap$ doap.php?id=$1
+RewriteRule ^([0-9]+)/edit$ edit.php?id=$1
+RewriteRule ^([0-9]+)/fork$ fork.php?id=$1
+RewriteRule ^([0-9]+)/raw/(.+)$ raw.php?id=$1&file=$2
+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 ^fork-remote$ fork-remote.php
+RewriteRule ^new$ new.php
-RewriteRule ^feed/new$ /feed-new.php
-RewriteRule ^feed/updated$ /feed-updated.php
+RewriteRule ^feed/new$ feed-new.php
+RewriteRule ^feed/updated$ feed-updated.php
-RewriteRule ^list$ /list.php
-RewriteRule ^list/([0-9]+)$ /list.php?page=$1
+RewriteRule ^list$ list.php
+RewriteRule ^list/([0-9]+)$ list.php?page=$1
-RewriteRule ^search$ /search.php
-RewriteRule ^search/([0-9]+)$ /search.php?page=$1
+RewriteRule ^search$ search.php
+RewriteRule ^search/([0-9]+)$ search.php?page=$1
-RewriteRule ^login$ /login.php
-RewriteRule ^user$ /user.php
+RewriteRule ^login$ login.php
+RewriteRule ^user$ user.php
#openid_url {
margin: 0px !important;
width: 250px;
- background: #FFF url(/images/openid-inputicon.gif) no-repeat scroll 0 50%;
+ background: #FFF url(../images/openid-inputicon.gif) no-repeat scroll 0 50%;
padding-left:18px;
}
.openid_large_btn {
float: left;
}
.google {
- background: #FFF url(/images/google.gif) no-repeat center center;
+ background: #FFF url(../images/google.gif) no-repeat center center;
}
.yahoo {
- background: #FFF url(/images/yahoo.gif) no-repeat center center;
+ background: #FFF url(../images/yahoo.gif) no-repeat center center;
}
a.openid_large_btn:hover {
throw new Exception_Input('Deleting only possible via POST');
}
$repo->delete();
- redirect('/');
+ redirect(Tools::fullUrl());
}
render(
$repopo = new Repository_Post($repo);
if ($repopo->process($_POST, $_SESSION)) {
- redirect($repo->getLink('display'));
+ redirect($repo->getLink('display', null, true));
}
render(
'feed-new',
array(
'pastes' => $db->getSearch()->listAll(0, 10, 'crdate', 'desc'),
- 'url' => Tools::fullUrl('/'),
- 'feedurl' => Tools::fullUrl('/feed/new'),
+ 'url' => Tools::fullUrl(),
+ 'feedurl' => Tools::fullUrl('feed/new'),
)
);
?>
'feed-updated',
array(
'pastes' => $db->getSearch()->listAll(0, 10, 'modate', 'desc'),
- 'url' => Tools::fullUrl('/'),
- 'feedurl' => Tools::fullUrl('/feed/updated'),
+ 'url' => Tools::fullUrl(),
+ 'feedurl' => Tools::fullUrl('feed/updated'),
)
);
?>
}
$forker = new Forker();
$new = $forker->forkRemote($gitUrl, $fr->getUrl());
- redirect($new->getLink('display'));
+ redirect($new->getLink('display', null, true));
} else {
//multiple urls found
$urls = $fr->getGitUrls();
$new = $forker->forkLocal($repo);
//FIXME: where to put fork source link?
-redirect($new->getLink('display'));
+redirect($new->getLink('display', null, true));
?>
header(
'Location: '
- . Tools::fullUrl('/' . $GLOBALS['phorkie']['cfg']['index'])
+ . Tools::fullUrl($GLOBALS['phorkie']['cfg']['index'])
);
?>
list($repos, $repoCount) = $rs->getList($page, $perPage);
$pager = new Html_Pager(
- $repoCount, $perPage, $page + 1, '/list/%d'
+ $repoCount, $perPage, $page + 1, 'list/%d'
);
$db = new Database();
if (isset($_REQUEST['logout'])) {
unset($_SESSION);
session_destroy();
- header('Location: ' . Tools::fullUrl('/'));
+ header('Location: ' . Tools::fullUrl());
exit();
}
$openid_url = null;
}
-$realm = Tools::fullUrl('/');
-$returnTo = Tools::fullUrl('/login');
+$realm = Tools::fullUrl();
+$returnTo = Tools::fullUrl('login');
try {
$o = new \OpenID_RelyingParty($returnTo, $realm, $openid_url);
setcookie('lastopenid', $_SESSION['identity'], time() + 84600 * 60, '/login');
+$url = '';
if (isset($_SESSION['REQUEST_URI'])) {
- $redirect = Tools::fullUrl($_SESSION['REQUEST_URI']);
-} else {
- $redirect = Tools::fullUrl('/');
+ $url = substr($_SESSION['REQUEST_URI'], 1);
}
+$redirect = Tools::fullUrl($url);
header('Location: ' . filter_var($redirect, FILTER_SANITIZE_URL));
exit;
?>
$repopo = new Repository_Post();
if ($repopo->process($_POST, $_SESSION)) {
- redirect($repopo->repo->getLink('display'));
+ redirect($repopo->repo->getLink('display', null, true));
}
$phork = array(
require_once 'www-header.php';
if (!isset($_GET['q']) || $_GET['q'] == '') {
- header('Location: ' . Tools::fullUrl('/list'));
+ header('Location: ' . Tools::fullUrl('list'));
exit();
}
$query = $_GET['q'];
function render($tplname, $vars = array())
{
+ $vars['baseurl'] = '/';
+ if (!empty($GLOBALS['phorkie']['cfg']['baseurl'])) {
+ $vars['baseurl'] = $GLOBALS['phorkie']['cfg']['baseurl'];
+ }
$vars['css'] = $GLOBALS['phorkie']['cfg']['css'];
$vars['title'] = $GLOBALS['phorkie']['cfg']['title'];
$vars['topbar'] = $GLOBALS['phorkie']['cfg']['topbar'];