Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Begin work on fixing mentions. #2

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions client/main.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<?php
// Float pinned posts to the top.
// If they share a pinned/unpinned status, later post comes to the top.
// Otherwise, force pinned post to the top.
// Sort the threads array so that pinned posts float to the top.
// If the threads share a pinned status (both pinned or both not),
// then the thread with the later creation time floats to the top.
// Otherwise, the pinned thread is forced to the top.
function pinned_sort($thread_a,$thread_b) {
if ($thread_a["pinned"] == $thread_b["pinned"]) {
return (($thread_a["last_mod"]>$thread_b["last_mod"])? -1 : 1);
Expand Down
12 changes: 11 additions & 1 deletion client/thread.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
<?php
function lookup($match) {
$data = $thread["data"];
$usermap = $thread["usermap"];
$postnum = $match[1];
if ($postnum==0) {
return ">>OP";
}
return ">>".$postnum.$usermap[$data["messages"][$postnum]["author"]]["user_name"];
}
foreach($thread["data"]["messages"] as $message) {
$username = $thread["usermap"][$message["author"]]["user_name"];
$time = round($message['created']);
Expand All @@ -7,7 +16,8 @@
echo "\t\t<div class='well' id='post{$message["post_id"]}'>".PHP_EOL;
echo "\t\t\t<p>&gt;{$message['post_id']} {$username} @ {$time}</p>".PHP_EOL;
echo "\t\t\t<pre>";
echo str_replace(">>0",">>OP",$message["body"]).PHP_EOL;
// echo str_replace(">>0",">>OP",$message["body"]).PHP_EOL;
echo preg_replace_callback("/>>(\d+)/",'lookup',$message["body"]).PHP_EOL;
echo "</pre>".PHP_EOL;
echo "\t\t</div>".PHP_EOL;
}
Expand Down