Ejemplo n.º 1
0
 public function actionTest()
 {
     echo \yii\helpers\Markdown::process('**strong text***emphasized text*');
     exit;
     //        echo Yii::getAlias('@yii/storage');
     return $this->render('test');
 }
Ejemplo n.º 2
0
 public function actionBlog()
 {
     $id = Yii::$app->request->get('id');
     $data = TblBlog::find()->joinwith('category')->where([TblBlog::tableName() . '.id' => $id])->asArray()->one();
     $data['text'] = Markdown::process($data['text'], 'gfm');
     return $this->render('article', ['data' => $data]);
 }
 public static function prepareForSave($model)
 {
     list($model->PostText, $imgs, $urls) = self::parseText($model->PostText);
     $model->PostTextParsed = Markdown::process($model->PostText);
     $model->PostHeader = self::createHeader(strip_tags($model->PostText));
     return [$model, $imgs, $urls];
 }
 protected function parseData($path)
 {
     preg_match('~guide-?(.*)/(.+)\\.md$~', $path, $matches);
     $language = $matches[1] ? $matches[1] : Yii::$app->sourceLanguage;
     $language = Locale::getPrimaryLanguage($language);
     $slug = strtolower($matches[2]);
     $doc = file_get_contents($path);
     $doc = Markdown::process($doc, 'gfm');
     $html = new HTMLDocument();
     @$html->loadHTML($doc);
     $html->addPrefix("/{lang}/", 'a', 'href');
     $imgPath = dirname($path) . '/images';
     $imgPath = $this->publishImages($imgPath);
     if ($imgPath) {
         $html->addPrefix(function ($src) use($imgPath) {
             return $imgPath . '/' . basename($src);
         }, 'img', 'src');
     }
     foreach (['h1', 'h2', 'h3', 'h4'] as $tag) {
         /** @var \DOMElement $item */
         foreach ($html->getElementsByTagName($tag) as $item) {
             /** @var \DOMElement $span */
             if ($span = $item->getElementsByTagName('span')[0]) {
                 $item->setAttribute('id', $span->getAttribute('id'));
             }
         }
     }
     /** @var DOMElement $title */
     $title = $html->getElementsByTagName('h1')[0];
     return ['language' => $language, 'slug' => $slug, 'title' => $title->textContent, 'description' => $html->saveHTML()];
 }
Ejemplo n.º 5
0
 /**
  * @inheritdoc
  */
 public function behaviors()
 {
     return [TimestampBehavior::className(), ['class' => AttributeBehavior::className(), 'attributes' => [ActiveRecord::EVENT_BEFORE_INSERT => 'alias'], 'value' => function ($event) {
         return Inflector::slug($event->sender->title);
     }], ['class' => AttributeBehavior::className(), 'attributes' => [ActiveRecord::EVENT_AFTER_FIND => 'body'], 'value' => function ($event) {
         return HtmlPurifier::process(Markdown::process($event->sender->content, 'gfm'));
     }]];
 }
Ejemplo n.º 6
0
 public function beforeSave($insert)
 {
     parent::beforeSave($insert);
     $this->historyTemp = new History();
     $this->historyTemp->attributes = ['title' => $this->title, 'content' => $this->content, 'user_id' => 1];
     $this->content = Markdown::process($this->content, 'gfm');
     if (!$this->isNewRecord) {
         $this->historyTemp->renderDiff($this->lastEdit);
     }
     return true;
 }
 public function up()
 {
     $works = Work::find()->all();
     foreach ($works as $work) {
         if ($work->description && strpos('<p>', $work->description) === false) {
             echo "Convert  {$work->id} 's description...\n";
             $work->description = Markdown::process($work->description, 'gfm');
             $work->save(false);
         }
     }
     echo "DOne\n";
 }
Ejemplo n.º 8
0
 /**
  * Converts markdown into HTML
  *
  * @param string $content
  * @param TypeDoc $context
  * @param boolean $paragraph
  * @return string
  */
 public static function process($content, $context = null, $paragraph = false)
 {
     if (!isset(Markdown::$flavors['api-latex'])) {
         Markdown::$flavors['api-latex'] = new static();
     }
     if (is_string($context)) {
         $context = static::$renderer->apiContext->getType($context);
     }
     Markdown::$flavors['api-latex']->renderingContext = $context;
     if ($paragraph) {
         return Markdown::processParagraph($content, 'api-latex');
     } else {
         return Markdown::process($content, 'api-latex');
     }
 }
Ejemplo n.º 9
0
 /**
  * @inheritdoc
  * @throws \InvalidArgumentException when params are not empty
  */
 public function render($view, $file, $params)
 {
     if (!empty($params)) {
         throw new \InvalidArgumentException('MdViewRenderer does not support params.');
     }
     if ($this->cache) {
         $key = self::CACHE_PREFIX . $file;
         $result = $this->cache->get($key);
         if ($result === false) {
             $result = Markdown::process(file_get_contents($file), $this->flavor);
             $this->cache->set($key, $result, 0, new FileDependency(['fileName' => $file]));
         }
     } else {
         $result = Markdown::process(file_get_contents($file), $this->flavor);
     }
     return $result;
 }
 /**
  * Helper function for the docs action
  * @return string
  */
 private function createHtml($file, $useRootPath = false)
 {
     \Yii::trace("Creating HTML for '{$file}'", __METHOD__);
     try {
         $filePath = \Yii::getAlias($this->module->markdownUrl) . '/' . $file;
         $markdown = file_get_contents($filePath);
         \Yii::trace("Loaded markdown for '{$filePath}'", __METHOD__);
     } catch (\Exception $e) {
         \Yii::$app->session->addFlash("error", "File '{$file}' not found,");
         return false;
     }
     $_slash = $useRootPath ? '' : '/';
     $html = Markdown::process($markdown, 'gfm');
     $html = preg_replace('|<a href="(?!http)' . $_slash . '(.+\\.md)">|U', '<a href="__INTERNAL_URL__$1">', $html);
     $dummyUrl = Url::to(['/' . $this->module->id . '/default/index', 'file' => '__PLACEHOLDER__']);
     $html = strtr($html, ['__INTERNAL_URL__' => $dummyUrl]);
     $html = strtr($html, ['__PLACEHOLDER__' => '']);
     return $html;
 }
Ejemplo n.º 11
0
 public function render($view, $file, $params)
 {
     return Markdown::process(file_get_contents($file));
 }
Ejemplo n.º 12
0
		<a href="index.php?r=post/searchby&text=">
		<?php 
        echo $t_el['name'];
        ?>
</a>,
		<?php 
    }
    ?>
	</div>




	<div class="post-body2">
		<?php 
    echo \yii\helpers\HtmlPurifier::process(\yii\helpers\Markdown::process(substr($post_el['text'], 0, 700) . ' ...'));
    ?>

	</div>
	<span style="float: right;padding-right: 1cm;">
	<?php 
    echo Html::a('Read more', ['post/view', 'id' => $post_el['post_id']], ['class' => 'btnread']);
    ?>
	</span>




<hr class="style-two">

Ejemplo n.º 13
0
          //
          //  The onchange event handler that typesets the
          //  math entered by the user
          //
          window.UpdateMath = function (TeX) {
            QUEUE.Push(["Text",math,"\\displaystyle{"+TeX+"}"]);
          }
        })();
      </script>
    <h1><?php 
echo Html::encode($this->title);
?>
</h1>

    <p>
        <?php 
echo Html::a('Изменить', ['update', 'id' => $model->id], ['class' => 'btn btn-primary']);
?>
        <?php 
echo Html::a('Удалить', ['delete', 'id' => $model->id], ['class' => 'btn btn-danger', 'data' => ['confirm' => 'Are you sure you want to delete this item?', 'method' => 'post']]);
?>
    </p>
    
    <?php 
echo DetailView::widget(['model' => $model, 'attributes' => ['name', ['attribute' => 'type_id', 'value' => $model->taskType->name], ['attribute' => 'text', 'value' => Markdown::process($model->text), 'format' => 'html']]]);
?>
    

</div>
<?php 
Pjax::end();
Ejemplo n.º 14
0
}
?>

    <?php 
if ($node) {
    echo \frontend\widgets\Panel::widget(['title' => \Yii::t('app', 'Same Node Topics'), 'items' => $sameTopics]);
}
?>

    <div class="panel panel-default corner-radius">
        <div class="panel-heading text-center">
            <h3 class="panel-title"><?php 
echo \Yii::t('app', 'Tips and Tricks');
?>
</h3>
        </div>
        <div class="panel-body">
            <?php 
echo \yii\helpers\Markdown::process($tips, 'gfm');
?>
        </div>
    </div>

    <?php 
\frontend\widgets\Panel::widget(['title' => \Yii::t('app', 'Site Status'), 'items' => []]);
?>


</div>
<div class="clearfix"></div>
Ejemplo n.º 15
0
 public function getMarkdown()
 {
     return Markdown::process($this->content, 'gfm');
 }
Ejemplo n.º 16
0
                        ·
                        <?php 
echo $model->view_count;
?>
 次阅读
                    </div>
                </div>
                <div class="avatar media-right">
                    <?php 
echo Html::a(Html::img($model->user->userAvatar, ['class' => 'media-object avatar-48']), ['/user/default/show', 'username' => $model->user['username']]);
?>
                </div>
            </div>
            <div class="panel-body article">
                <?php 
echo HtmlPurifier::process(Markdown::process($model->content, 'gfm'));
?>

                <?php 
if ($donate) {
    ?>
                    <hr/>
                    <div style="text-align: center; color: #666;">
                        <?php 
    echo Html::button('打赏作者', ['class' => 'btn btn-danger', 'id' => 'donate-btn']);
    ?>
                        <p></p>
                        <p><?php 
    echo $donate->description;
    ?>
</p>
Ejemplo n.º 17
0
echo $model->author->name . ' 发表于 ' . date('Y年m月d日', $model->created_at);
?>
        </p>
    </div>
    <div class="content">
        <p>
        <?php 
if (mb_strlen($model->content) > 300) {
    $content = mb_substr($model->content, 0, 300, 'UTF-8');
    $content .= '...';
} else {
    $content = $model->content;
}
?>
        <?php 
echo \yii\helpers\Markdown::process($content);
?>
        </p>
    </div>
    <nav class="navbar navbar-default" role="navigation"  style="padding:15px 5px">

        <span><b>标签:  </b>
        <?php 
$tags = explode(',', $model->tags);
foreach ($tags as $tag) {
    echo $tag, ' ';
}
?>
        </span>
        <span class="pull-right"><?php 
echo Html::a("Comments ({$model->commentCount})", $model->url . '#comments');
Ejemplo n.º 18
0
 public static function markdown2html($str)
 {
     return Markdown::process($str);
 }
Ejemplo n.º 19
0
echo $form->field($model, 'content')->widget('trntv\\aceeditor\\AceEditor', ['id' => 'markdown', 'mode' => 'markdown', 'containerOptions' => ['style' => 'width: 100%; min-height: 350px'], 'theme' => 'github']);
?>
    </div>

    <?php 
echo SelectizeTextInput::widget(['name' => 'Topic[tags]', 'value' => $model->tags, 'loadUrl' => ['/post-tag/index'], 'clientOptions' => ['placeholder' => '标签(可选)', 'allowEmptyOption' => false, 'delimiter' => ',', 'valueField' => 'name', 'labelField' => 'name', 'searchField' => 'name', 'maxItems' => 5, 'plugins' => ['remove_button'], 'persist' => false, 'create' => true]]);
?>

    <div class="form-group">
        <?php 
echo Html::submitButton($model->isNewRecord ? '创建话题' : '修改话题', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']);
?>

        <div class="pull-right">
            <?php 
echo Html::a('排版说明', ['/site/markdown'], ['target' => '_blank']);
?>
        </div>
    </div>

    <div id="md-preview" class="pt10">
        <?php 
echo HtmlPurifier::process(\yii\helpers\Markdown::process($model->content, 'gfm'));
?>
    </div>

    <?php 
ActiveForm::end();
?>

</div>
Ejemplo n.º 20
0
/* @var $this yii\web\View */
/* @var $dataProvider yii\data\ActiveDataProvider */
$this->title = $model->title;
$this->params['breadcrumbs'][] = $this->title;
?>

<div class="panel panel-info">
    <div class="panel-heading">
        <h3><?php 
echo Html::encode($model->title);
?>
</h3>
    </div>
    <div class="panel-body">
        <?php 
echo \yii\helpers\Markdown::process($model->content);
?>
    </div>
    <div class="panel-footer">
        <h4><b>标签:   </b>
        <?php 
$tags = explode(',', $model->tags);
foreach ($tags as $tag) {
    echo $tag, ' ';
}
?>
        </h4>
    </div>
</div>

<br/>
Ejemplo n.º 21
0
"><?php 
    echo $c['username'];
    ?>
</a> 提的建议 <a href="/topic/<?php 
    echo $c['topic_id'];
    ?>
"> <?php 
    echo $c['title'];
    ?>
</a> &nbsp;&nbsp;<?php 
    echo Yii::$app->formatter->asRelativeTime($c['created']);
    ?>
</small></aside>
                        </div>
                        <div class="mt10 markdown-content"><?php 
    echo \common\components\Helper::autoLink(\yii\helpers\HtmlPurifier::process(\yii\helpers\Markdown::process($c['content'], 'gfm-comment')));
    ?>
</div>
                        <div class="clearfix"></div>
                    </div>
                </article>
            <?php 
}
?>
            <div class="block-footer"><a href="/member/<?php 
echo $model->username;
?>
/reply"><?php 
echo $model->username;
?>
 的更多回复</a></div>
Ejemplo n.º 22
0
']=false">

                            <div class="help-overlay" ng-show="isHover['<?php 
    echo $name;
    ?>
']">
                                <h3 class="help-overlay__title"><?php 
    echo $name;
    ?>
</h3>
                                <code class="help-overlay__example-code"><?php 
    echo $object->example();
    ?>
</code>
                                <div class="help-overlay__description"><?php 
    echo Markdown::process($object->readme());
    ?>
</div>
                            </div>

                            <div><?php 
    echo $name;
    ?>
<a class="secondary-content"><i class="material-icons">content_paste</i></a></div>
                        </li>
                    <?php 
}
?>
                    </ul>
                  </div>
                </li>
Ejemplo n.º 23
0
}
$this->registerJsFile("@web/highlight/highlight.pack.js");
$this->registerCssFile("@web/highlight/styles/github.css");
$this->registerJs("hljs.initHighlightingOnLoad();");
?>

<div class="col-xs-12 col-sm-9">
    <div class="row">
        <div class="col-6 col-sm-6 col-lg-12 panel">
            <h2><?php 
echo $article->title;
?>
</h2>
            <hr />
            <p><?php 
echo Markdown::process($article->content, 'gfm');
?>
</p>
            <a name="comments"></a>
            <p>
                <i class="glyphicon glyphicon-calendar"></i><span><?php 
echo $article->created_at;
?>
(<?php 
echo Str::friendlyDate($article->created_at);
?>
)</span>
            </p>
        </div><!--/span-->

        <div class="col-6 col-sm-6 col-lg-12 panel">
Ejemplo n.º 24
0
 /**
  * @inheritdoc
  */
 public function behaviors()
 {
     return [TimestampBehavior::className(), ['class' => AttributeBehavior::className(), 'attributes' => [ActiveRecord::EVENT_AFTER_FIND => 'body'], 'value' => function ($event) {
         return HtmlPurifier::process(Markdown::process($event->sender->content, 'gfm-comment'));
     }], ['class' => BlameableBehavior::className(), 'attributes' => [ActiveRecord::EVENT_BEFORE_INSERT => 'user_id']]];
 }
Ejemplo n.º 25
0
<?php

use yii\helpers\Markdown;
$NodeLink = \common\models\NodeLink::NodeLink($node);
if (!empty($NodeLink)) {
    ?>
<section>
    <div class="block-content markdown-content">
        <?php 
    foreach ($NodeLink as $link) {
        ?>
        <?php 
        echo Markdown::process($link['content'], 'gfm');
        ?>
        <?php 
    }
    ?>
    </div>
</section>
<?php 
}
Ejemplo n.º 26
0
Archivo: page.php Proyecto: npk/v2sex
$this->params['breadcrumbs'][] = $model->title;
?>
<div class="row">
    <div class="col-md-9">
        <section>
            <?php 
echo yii\widgets\Breadcrumbs::widget(['links' => isset($this->params['breadcrumbs']) ? $this->params['breadcrumbs'] : []]);
?>
            <article class="<?php 
echo $model->route;
?>
">
                <div class="row">
                    <div class="col-lg-9 markdown-content">
                        <?php 
echo Markdown::process($model->content, 'gfm');
?>
                    </div>
                </div>
            </article>
        </section>
    </div>

    <div class="col-md-3 sidebar">
        <?php 
echo $this->render('@frontend/views/weight/user');
?>
        <?php 
echo $this->render('@frontend/views/weight/hot-topic');
?>
        <?php 
Ejemplo n.º 27
0
/* @var $question app\modules\poll\models\Question */
/* @var $answers app\modules\poll\models\Answer[] */
/* @var $form yii\widgets\ActiveForm */
?>

<div class="vote-form">

    <?php 
$form = ActiveForm::begin();
?>
    <h3><?php 
echo $question->title;
?>
</h3>
    <p><?php 
echo $question->isAuto() ? '<pre>' . $question->description . '</pre>' : \yii\helpers\Markdown::process($question->description);
?>
</p>
    <table class="table table-stripped">
        <tbody>
        <?php 
foreach ($answers as $answer) {
    ?>
        <tr>
            <td><?php 
    echo $answer->title;
    ?>
</td>
            <td><?php 
    echo $answer->voteCount;
    ?>
Ejemplo n.º 28
0
#### 基于Yii2

- [GetYii](https://github.com/iiYii/getyii)
- [huajuan](https://github.com/callmez/huajuan)
- [dcms2](https://github.com/djfly/dcms2)
- [yii2-adminlte](https://github.com/funson86/yii2-adminlte)
- [yii2-simple](https://github.com/azraf/yii2-simple)
- [dotplant2](https://github.com/DevGroup-ru/dotplant2)


### 贡献者

- [forecho](/member/forecho)

### 最后

欢迎大家跟我联系提供更多资料。
';
?>
<div class="container p0">
    <div class="panel panel-default">
        <div class="panel-heading">
            Wiki 列表
        </div>
        <div class="panel-body">
            <?php 
echo Markdown::process($content, 'gfm');
?>
        </div>
    </div>
</div>
Ejemplo n.º 29
0
    $baseDir = '';
    $this->title = substr($page, 0, strrpos($page, '.'));
} else {
    $baseDir = substr($page, 0, $pos) . '/';
    $this->title = substr($page, $pos + 1, strrpos($page, '.') - $pos - 1);
}
if ($page == 'README.md') {
    $this->params['breadcrumbs'][] = 'Readme';
    $menus = $this->context->module->getMenus();
    $links = [];
    foreach ($menus as $menu) {
        $url = Url::to($menu['url'], true);
        $links[] = "[**{$menu['label']}**]({$url})";
    }
    $body = str_replace(':smile:.', ".\n\n" . implode('  ', $links) . "\n", $this->render("@thinkwill/admin/README.md"));
} else {
    $body = $this->render("@thinkwill/admin/{$page}");
}
$body = preg_replace_callback('/\\]\\((.*?)\\)/', function ($matches) use($baseDir) {
    $link = $matches[1];
    if (strpos($link, '://') === false) {
        if ($link[0] == '/') {
            $link = Url::current(['page' => ltrim($link, '/')], true);
        } else {
            $link = Url::current(['page' => $baseDir . $link], true);
        }
    }
    return "]({$link})";
}, $body);
echo Markdown::process($body, 'gfm');
Ejemplo n.º 30
-1
 public function actionRss()
 {
     /** @var News[] $news */
     $news = News::find()->where(['status' => News::STATUS_PUBLIC])->orderBy('id DESC')->limit(50)->all();
     $feed = new Feed();
     $feed->title = 'YiiFeed';
     $feed->link = Url::to('');
     $feed->selfLink = Url::to(['news/rss'], true);
     $feed->description = 'Yii news';
     $feed->language = 'en';
     $feed->setWebMaster('*****@*****.**', 'Alexander Makarov');
     $feed->setManagingEditor('*****@*****.**', 'Alexander Makarov');
     foreach ($news as $post) {
         $item = new Item();
         $item->title = $post->title;
         $item->link = Url::to(['news/view', 'id' => $post->id], true);
         $item->guid = Url::to(['news/view', 'id' => $post->id], true);
         $item->description = HtmlPurifier::process(Markdown::process($post->text));
         if (!empty($post->link)) {
             $item->description .= Html::a(Html::encode($post->link), $post->link);
         }
         $item->pubDate = $post->created_at;
         $item->setAuthor('*****@*****.**', 'YiiFeed');
         $feed->addItem($item);
     }
     $feed->render();
 }