This commit is contained in:
cornernote 2015-08-09 19:31:05 +09:30
parent 6296d46139
commit 6e92de1b36
9 changed files with 58 additions and 62 deletions

View File

@ -32,19 +32,14 @@ class Git
if (strpos($endpoint, 'github.com')) {
return self::getGitHubComUrl($endpoint, $file);
}
if (strpos($endpoint, 'bitbucket.org')) {
return self::getBitBucketOrgUrl($endpoint, $file);
}
if (strpos($endpoint, 'notabug.org')) {
return self::getBitBucketOrgUrl($endpoint, $file);
}
if (strpos($endpoint, 'gitlab.com')) {
return self::getBitBucketOrgUrl($endpoint, $file);
}
if (strpos($endpoint, 'repo.or.cz')) {
return self::getRepoOrCzUrl($endpoint, $file);
}
return false;
return strtr($endpoint, [
'http://' => 'https://',
'git://' => 'https://',
'.git' => $file ? '/raw/master/' . $file : '/',
]);
}
/**
@ -62,20 +57,6 @@ class Git
]);
}
/**
* @param $endpoint
* @param $file
* @return string
*/
private static function getBitBucketOrgUrl($endpoint, $file)
{
return strtr($endpoint, [
'http://' => 'https://',
'git://' => 'https://',
'.git' => $file ? '/raw/master/' . $file : '/',
]);
}
/**
* @param $endpoint
* @param $file

View File

@ -30,6 +30,7 @@ $web = [
'packages/<name:\w+>' => 'package/view',
'packages' => 'package/index',
// mods
'submit' => 'mod/create',
'mods/update/<name:\w+>' => 'mod/update',
'mods/<name:\w+>' => 'mod/view',
'mods' => 'mod/index',

View File

@ -13,9 +13,9 @@ class DocsController extends Controller
return $this->render('index');
}
public function actionBowerJsonFormat()
public function actionBowerFormat()
{
return $this->render('bower-json-format');
return $this->render('bower-format');
}
}

View File

@ -2,10 +2,15 @@
/* @var $this yii\web\View */
$this->title = 'Minetest bower.json specification';
?>
<div class="site-bower-json-format">
use yii\helpers\Html;
$this->title = 'bower.json Format';
$this->params['breadcrumbs'][] = ['label' => 'Docs', 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="docs-bower-json-format">
<h1><?= Html::encode($this->title) ?></h1>
<h2>Example <code>bower.json</code></h2>
@ -138,9 +143,15 @@ $this->title = 'Minetest bower.json specification';
<ul>
<li>Key must be a valid <code>name</code>.</li>
<li>Value must be a valid <a href="https://github.com/npm/node-semver#ranges">semver range</a>, a Git URL, or a URL (inc. tarball and zipball).</li>
<li>Git URLs can be restricted to a reference (revision SHA, branch, or tag) by appending it after a hash, e.g. <code>https://github.com/owner/package.git#branch</code>.</li>
<li>Value can be an owner/package shorthand, i.e. owner/package. By default, the shorthand resolves to GitHub -> git://github.com/{{owner}}/{{package}}.git. This may be changed in <code>.bowerrc</code> <a href="http://bower.io/docs/config/#shorthand-resolver">shorthand_resolver</a>.</li>
<li>Value must be a valid
<a href="https://github.com/npm/node-semver#ranges">semver range</a>, a Git URL, or a URL (inc. tarball and zipball).
</li>
<li>Git URLs can be restricted to a reference (revision SHA, branch, or tag) by appending it after a hash, e.g.
<code>https://github.com/owner/package.git#branch</code>.
</li>
<li>Value can be an owner/package shorthand, i.e. owner/package. By default, the shorthand resolves to GitHub -> git://github.com/{{owner}}/{{package}}.git. This may be changed in
<code>.bowerrc</code> <a href="http://bower.io/docs/config/#shorthand-resolver">shorthand_resolver</a>.
</li>
<li>Local paths may be used as values for local development, but they will be disallowed when registering.</li>
</ul>

23
src/views/docs/index.php Normal file
View File

@ -0,0 +1,23 @@
<?php
/* @var $this yii\web\View */
use yii\bootstrap\Nav;
use yii\helpers\Html;
$this->title = 'Documentation';
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="docs-index">
<h1><?= Html::encode($this->title) ?></h1>
<?php
echo Nav::widget([
'items' => [
['label' => 'bower.json Format', 'url' => ['/docs/bower-format']],
],
]);
?>
</div>

View File

@ -39,6 +39,7 @@ echo Nav::widget([
//['label' => 'Home', 'url' => ['/site/index']],
['label' => 'Browse', 'url' => ['/mod/index']],
['label' => 'Submit', 'url' => ['/mod/create']],
['label' => 'Docs', 'url' => ['/docs/index']],
],
]);
echo Nav::widget([

View File

@ -6,7 +6,7 @@ use yii\helpers\Html;
/* @var $this yii\web\View */
/* @var $model app\models\Package */
$this->title = 'Create Package';
$this->title = 'Submit Mod';
$this->params['breadcrumbs'][] = ['label' => 'Mods', 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
?>

View File

@ -1,21 +0,0 @@
<?php
use yii\helpers\Html;
/* @var $this yii\web\View */
/* @var $model app\models\Package */
$this->title = 'Update Package: ' . ' ' . $model->name;
$this->params['breadcrumbs'][] = ['label' => 'Packages', 'url' => ['index']];
$this->params['breadcrumbs'][] = ['label' => $model->name, 'url' => ['view', 'id' => $model->id]];
$this->params['breadcrumbs'][] = 'Update';
?>
<div class="package-update">
<h1><?= Html::encode($this->title) ?></h1>
<?= $this->render('_form', [
'model' => $model,
]) ?>
</div>

View File

@ -32,25 +32,25 @@ $this->params['jumbotron'] = '/site/_index-jumbotron';
}</pre>
</div>
<div class="col-lg-6">
<h2>Install Packages</h2>
<h2>Install Mods</h2>
<p>Install packages with <code>bower install</code>.</p>
<pre>$ bower install &lt;package&gt;</pre>
<p>Install mods with <code>bower install</code>.</p>
<pre>$ bower install &lt;mod&gt;</pre>
<h2>Create Packages</h2>
<h2>Create Mods</h2>
<p>Create packages with
<p>Create mods with
<code>bower register</code> or <?= Html::a('submit a mod online', ['/mod/create']) ?>.</p>
<pre>$ bower register &lt;my_mod_name&gt; &lt;git_endpoint&gt;
# for example
$ bower register example https://github.com/user/example.git</pre>
<h2>Package Information</h2>
<h2>Mod Information</h2>
<p>Package information is collected from a <code>bower.json</code> file in the repository</p>
<p>Mod information is collected from a <code>bower.json</code> file in the repository</p>
<p><?= Html::a('bower.json format &raquo;', ['/docs/bower-json-format'], ['class' => 'btn btn-sm btn-default']); ?></p>
<p><?= Html::a('bower.json format &raquo;', ['/docs/bower-format'], ['class' => 'btn btn-sm btn-default']); ?></p>
</div>
</div>