Store parsed bbcode
This commit is contained in:
parent
64100805fd
commit
d8f72b729b
2 changed files with 43 additions and 4 deletions
|
@ -71,7 +71,7 @@ class Post
|
|||
* The parsed contents of this post.
|
||||
* @var string
|
||||
*/
|
||||
public $parsed = "";
|
||||
public $parsed = null;
|
||||
|
||||
/**
|
||||
* The UNIX timestamp of the last time this post was edited.
|
||||
|
@ -117,6 +117,7 @@ class Post
|
|||
$this->time = intval($postRow->post_time);
|
||||
$this->subject = $postRow->post_subject;
|
||||
$this->text = $postRow->post_text;
|
||||
$this->parsed = $postRow->post_text_parsed;
|
||||
$this->editTime = intval($postRow->post_edit_time);
|
||||
$this->editReason = $postRow->post_edit_reason;
|
||||
$this->editUser = User::construct($postRow->post_edit_user);
|
||||
|
@ -129,10 +130,12 @@ class Post
|
|||
$this->ip = $postRow->poster_ip;
|
||||
$this->update();
|
||||
}
|
||||
}
|
||||
|
||||
// Parse the markup
|
||||
if (strlen($this->parsed) < 1) {
|
||||
$this->parsed = BBParser::toHTML(htmlentities($this->text));
|
||||
$this->update();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -168,6 +171,7 @@ class Post
|
|||
'post_time' => time(),
|
||||
'post_subject' => $subject,
|
||||
'post_text' => $text,
|
||||
'post_text_parsed' => BBParser::toHTML(htmlentities($text)),
|
||||
]);
|
||||
|
||||
// Update the last post date
|
||||
|
@ -197,6 +201,7 @@ class Post
|
|||
'post_time' => $this->time,
|
||||
'post_subject' => $this->subject,
|
||||
'post_text' => $this->text,
|
||||
'post_text_parsed' => BBParser::toHTML(htmlentities($this->text)),
|
||||
'post_edit_time' => $this->editTime,
|
||||
'post_edit_reason' => $this->editReason,
|
||||
'post_edit_user' => $this->editUser->id,
|
||||
|
|
34
database/2016_10_07_174622_cache_parsed_bbcode.php
Normal file
34
database/2016_10_07_174622_cache_parsed_bbcode.php
Normal file
|
@ -0,0 +1,34 @@
|
|||
<?php
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Sakura\DB;
|
||||
|
||||
class CacheParsedBbcode extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
$schema = DB::getSchemaBuilder();
|
||||
|
||||
$schema->table('posts', function (Blueprint $table) {
|
||||
$table->text('post_text_parsed')
|
||||
->nullable();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
$schema = DB::getSchemaBuilder();
|
||||
|
||||
$schema->table('posts', function (Blueprint $table) {
|
||||
$table->dropColumn('post_text_parsed');
|
||||
});
|
||||
}
|
||||
}
|
Reference in a new issue