allow text readme, fixes #3
This commit is contained in:
parent
e5954bf8f4
commit
ac85b27860
19
src/migrations/m150810_000001_update_package.php
Normal file
19
src/migrations/m150810_000001_update_package.php
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use yii\db\Migration;
|
||||||
|
use yii\db\Schema;
|
||||||
|
|
||||||
|
class m150810_000001_update_package extends Migration
|
||||||
|
{
|
||||||
|
const TABLE = '{{%package}}';
|
||||||
|
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
$this->addColumn(self::TABLE, 'readme_format', Schema::TYPE_STRING . '(8)');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
$this->dropColumn(self::TABLE, 'readme_format');
|
||||||
|
}
|
||||||
|
}
|
@ -19,6 +19,7 @@ use yii\helpers\Html;
|
|||||||
* @property integer $hits
|
* @property integer $hits
|
||||||
* @property string $bower
|
* @property string $bower
|
||||||
* @property string $readme
|
* @property string $readme
|
||||||
|
* @property string $readme_format
|
||||||
* @property string $description
|
* @property string $description
|
||||||
* @property string $homepage
|
* @property string $homepage
|
||||||
* @property string $keywords
|
* @property string $keywords
|
||||||
@ -134,12 +135,21 @@ class Package extends ActiveRecord
|
|||||||
public function harvestModInfo()
|
public function harvestModInfo()
|
||||||
{
|
{
|
||||||
// get README.md
|
// get README.md
|
||||||
$this->readme = Git::getFile($this->url, 'README.md');
|
foreach (['README.md', 'readme.md', 'Readme.md'] as $file) {
|
||||||
if (!$this->readme) {
|
$this->readme = Git::getFile($this->url, $file);
|
||||||
$this->readme = Git::getFile($this->url, 'readme.md');
|
if ($this->readme) {
|
||||||
|
$this->readme_format = 'markdown';
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (!$this->readme) {
|
if (!$this->readme) {
|
||||||
$this->readme = Git::getFile($this->url, 'Readme.md');
|
foreach (['README.txt', 'readme.txt', 'Readme.txt', 'README', 'readme'] as $file) {
|
||||||
|
$this->readme = Git::getFile($this->url, $file);
|
||||||
|
if ($this->readme) {
|
||||||
|
$this->readme_format = 'text';
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// get bower.json
|
// get bower.json
|
||||||
@ -260,7 +270,15 @@ class Package extends ActiveRecord
|
|||||||
*/
|
*/
|
||||||
public function getReadmeHtml()
|
public function getReadmeHtml()
|
||||||
{
|
{
|
||||||
$parser = new GithubMarkdown();
|
if ($this->readme_format && $this->readme) {
|
||||||
return $parser->parse($this->readme);
|
if ($this->readme_format == 'markdown') {
|
||||||
|
$parser = new GithubMarkdown();
|
||||||
|
return $parser->parse($this->readme);
|
||||||
|
}
|
||||||
|
if ($this->readme_format == 'text') {
|
||||||
|
return '<pre>' . $this->readme . '</pre>';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return '';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -74,9 +74,7 @@ $this->params['breadcrumbs'][] = $this->title;
|
|||||||
]) ?>
|
]) ?>
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
if ($model->readme) {
|
echo $model->getReadmeHtml();
|
||||||
echo $model->getReadmeHtml();
|
|
||||||
}
|
|
||||||
?>
|
?>
|
||||||
|
|
||||||
<?php if (!$model->bower) { ?>
|
<?php if (!$model->bower) { ?>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user