Skip to content
Permalink
Browse files

Some fixes and refinements

  • Loading branch information...
OtakuMegane committed Apr 12, 2019
1 parent 8e1850c commit a87ff24d9eb3846174883a70a69b8a0c20384c6d
@@ -111,14 +111,15 @@ nelliel.ui.expandCollapseThread = function(element, command, dynamic = false) {

var content_id = nelliel.core.contentID(element.getAttribute("data-content-id"));
var target_element = document.getElementById("thread-expand-" + content_id.id_string);

var split_command = command.split("-");

if (!target_element) {
return;
}

if (dynamic) {
var url = "imgboard.php?module=render&action=" + command + "&board_id=" + dataBin.board_id + "&thread=" + content_id.thread_id;
var url = "imgboard.php?module=render&action=view-thread&content-id=" + content_id.id_string + "&board_id=" + dataBin.board_id + "&thread=" + content_id.thread_id;

if(dataBin.is_modmode) {
url = url + "&modmode=true";
}
@@ -19,6 +19,7 @@ abstract class OutputCore
protected $output_filter;
protected $url_constructor;
protected $timer_start;
protected $timer_stored;
protected $core_id;
public abstract function render(array $parameters, bool $data_only);
@@ -49,22 +50,31 @@ protected function selectRenderCore(string $core_id)
}
}
protected function startTimer()
protected function startTimer($time_offset = 0)
{
$start = microtime(true);
$this->timer_start = $start;
$this->timer_start = $start - $time_offset;
return $start;
}
protected function endTimer()
protected function endTimer($rounded = true)
{
if (!isset($this->timer_start))
{
return 0;
}
$end_time = microtime(true);
return round($end_time - $this->timer_start, 4);
if($rounded)
{
return round($end_time - $this->timer_start, 4);
}
else
{
return $end_time - $this->timer_start;
}
}
protected function output(string $template, bool $data_only, bool $translate, array $render_data = array(), $dom = null)
@@ -50,19 +50,21 @@ private function general(array $parameters, bool $data_only)
$dotdot = $parameters['dotdot'] ?? '';
$manage_headers = $parameters['manage_headers'] ?? array();
$this->render_data['show_styles'] = $parameters['show_styles'] ?? true;
$this->render_data['session_active'] = $session->isActive();
$ignore_session = $parameters['ignore_session'] ?? false;
$this->render_data['session_active'] = $session->isActive() && !$ignore_session;
$output_head = new OutputHead($this->domain);
$this->render_data['head'] = $output_head->render(['dotdot' => $dotdot], true);
$output_menu = new OutputMenu($this->domain);
$this->render_data['show_manage_headers'] = $session->isActive() && !empty($manage_headers);
if ($this->render_data['show_styles'])
{
$this->render_data['styles'] = $output_menu->render(['menu' => 'styles', 'dotdot' => $dotdot], true);
$this->render_data['styles'] = $output_menu->render(
['menu' => 'styles', 'dotdot' => $dotdot, 'ignore_session' => $ignore_session], true);
}
$this->render_data['site_navigation'] = $output_menu->render(
['menu' => 'site_navigation', 'dotdot' => $dotdot], true);
['menu' => 'site_navigation', 'dotdot' => $dotdot, 'ignore_session' => $ignore_session], true);
if (isset($parameters['use_site_titles']) && $parameters['use_site_titles'])
{
@@ -109,20 +111,22 @@ private function board(array $parameters, bool $data_only)
$manage_headers = $parameters['manage_headers'] ?? array();
$treeline = $parameters['treeline'] ?? array();
$index_render = $parameters['index_render'] ?? false;
$ignore_session = $parameters['ignore_session'] ?? false;
$this->render_data['show_styles'] = $parameters['show_styles'] ?? true;
$this->render_data['session_active'] = $session->isActive();
$this->render_data['session_active'] = $session->isActive() && !$ignore_session;
$output_head = new OutputHead($this->domain);
$this->render_data['head'] = $output_head->render(['dotdot' => $dotdot], true);
$output_menu = new OutputMenu($this->domain);
$this->render_data['show_manage_headers'] = $session->isActive() && !empty($manage_headers);
if ($this->render_data['show_styles'])
{
$this->render_data['styles'] = $output_menu->render(['menu' => 'styles', 'dotdot' => $dotdot], true);
$this->render_data['styles'] = $output_menu->render(
['menu' => 'styles', 'dotdot' => $dotdot, 'ignore_session' => $ignore_session], true);
}
$this->render_data['site_navigation'] = $output_menu->render(
['menu' => 'site_navigation', 'dotdot' => $dotdot], true);
['menu' => 'site_navigation', 'dotdot' => $dotdot, 'ignore_session' => $ignore_session], true);
$this->render_data['board_name'] = ($this->domain->setting('show_board_name')) ? $this->domain->setting(
'board_name') : '';
@@ -43,8 +43,8 @@ public function render(array $parameters, bool $data_only)
}
else
{
$this->render_data['header'] = $output_header->render(['header_type' => 'board', 'dotdot' => $dotdot],
true);
$this->render_data['header'] = $output_header->render(
['header_type' => 'board', 'dotdot' => $dotdot, 'ignore_session' => true], true);
}
$result = $this->database->query(
@@ -54,7 +54,7 @@ public function render(array $parameters, bool $data_only)
$thread_count = count($thread_list);
$gen_data['index']['thread_count'] = $thread_count;
$output_posting_form = new \Nelliel\Output\OutputPostingForm($this->domain);
$this->render_data['body'] = $output_posting_form->render(['dotdot' => $dotdot, 'response_to' => 0], false);
$this->render_data['posting_form'] = $output_posting_form->render(['dotdot' => $dotdot, 'response_to' => 0], false);
if (empty($thread_list))
{
@@ -86,9 +86,11 @@ public function render(array $parameters, bool $data_only)
$page = 1;
$page_count = (int) ceil($thread_count / $this->domain->setting('threads_per_page'));
$threads_on_page = 0;
$timer_offset = $this->endTimer(false);
foreach ($thread_list as $thread_data)
{
$this->startTimer($timer_offset);
$thread_input = array();
$prepared = $this->database->prepare(
'SELECT * FROM "' . $this->domain->reference('posts_table') .
@@ -108,6 +110,7 @@ public function render(array $parameters, bool $data_only)
$gen_data['abbreviate'] = $thread_data['post_count'] > $this->domain->setting('abbreviate_thread');
$thread_input['abbreviate'] = $gen_data['abbreviate'];
$abbreviate_start = $thread_data['post_count'] - ($this->domain->setting('abbreviate_thread') - 1);
$this->render_data['body'] = $this->render_data['posting_form'];
$post_counter = 0;
foreach ($treeline as $post_data)
@@ -190,6 +193,7 @@ public function render(array $parameters, bool $data_only)
$threads_on_page = 0;
$this->render_core->clearOutput();
$this->render_data['body'] = array();
$this->render_data['threads'] = array();
$page ++;
}
@@ -93,8 +93,9 @@ private function siteNavigation(array $parameters, bool $data_only)
$session = new \Nelliel\Session();
$site_domain = new \Nelliel\DomainSite($this->database);
$dotdot = ($parameters['dotdot']) ?? '';
$ignore_session = $parameters['ignore_session'] ?? false;
if ($session->isActive())
if ($session->isActive() && !$ignore_session)
{
$render_data['session_active'] = true;
$render_data['manage_url'] = $dotdot . MAIN_SCRIPT . '?module=main-panel';
@@ -133,13 +133,13 @@ public function getPostFromDatabase($post_id)
private function postHeaders(bool $response, array $thread_data, array $post_data, ContentID $thread_content_id,
ContentID $post_content_id, array $web_paths, array $gen_data)
{
$header_data = array();
$modmode_headers = array();
$thread_headers = array();
$authorization = new \Nelliel\Auth\Authorization($this->database);
$session = new \Nelliel\Session();
$cites = new \Nelliel\Cites($this->domain->database());
$header_data['response'] = $response;
$header_data = array();
$modmode_headers = array();
$thread_headers = array();
// TODO: Convert to passed $web_paths values
$base_domain_path = BASE_DOMAIN . BASE_WEB_PATH;
@@ -184,7 +184,7 @@ private function postHeaders(bool $response, array $thread_data, array $post_dat
rawurlencode($ip) . '&modmode=true';
$modmode_headers['delete_url'] = '?module=threads-admin&board_id=' . $this->domain->id() .
'&action=delete&content-id=' . $temp_content_id->getIDString() . '&modmode=true';
$modmode_headerss['ban_delete_irl'] = '?module=threads-admin&board_id=' . $this->domain->id() .
$modmode_headers['ban_delete_url'] = '?module=threads-admin&board_id=' . $this->domain->id() .
'&action=ban-delete&content-id=' . $temp_content_id->getIDString() . '&ban_type=POST&ban_ip=' .
rawurlencode($ip) . '&modmode=true';
$header_data['modmode_headers'] = $modmode_headers;
@@ -48,8 +48,8 @@ public function render(array $parameters = array(), bool $data_only = false)
}
else
{
$this->render_data['header'] = $output_header->render(['header_type' => 'board', 'dotdot' => $dotdot],
true);
$this->render_data['header'] = $output_header->render(
['header_type' => 'board', 'dotdot' => $dotdot, 'ignore_session' => true], true);
}
if (empty($thread_data))
@@ -77,7 +77,8 @@ public function render(array $parameters = array(), bool $data_only = false)
$total_posts = $thread_data['post_count'];
$this->render_data['abbreviate'] = false;
$output_posting_form = new \Nelliel\Output\OutputPostingForm($this->domain);
$this->render_data['body'] = $output_posting_form->render(['dotdot' => $dotdot, 'response_to' => $thread_id], false);
$this->render_data['body'] = $output_posting_form->render(['dotdot' => $dotdot, 'response_to' => $thread_id],
false);
$output_post = new \Nelliel\Output\OutputPost($this->domain);
$this->render_data['op_post'] = '';
$this->render_data['thread_posts'] = '';
@@ -124,12 +125,6 @@ public function render(array $parameters = array(), bool $data_only = false)
$this->file_handler->writeFile(
$this->domain->reference('page_path') . $thread_id . '/thread-' . $thread_id . '.html', $output,
FILE_PERM, true);
$this->file_handler->writeFile(
$this->domain->reference('page_path') . $thread_id . '/thread-' . $thread_id . '-expand.html',
$this->render_core->getOutput('expand'), FILE_PERM, true);
$this->file_handler->writeFile(
$this->domain->reference('page_path') . $thread_id . '/thread-' . $thread_id . '-collapse.html',
$this->render_core->getOutput('collapse'), FILE_PERM, true);
$json_thread->writeStoredData($this->domain->reference('page_path') . $thread_id . '/',
sprintf('thread-%d', $thread_id));
}

0 comments on commit a87ff24

Please sign in to comment.
You can’t perform that action at this time.