-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add hashtag hyperlinks and trending cloud (#492)
- Loading branch information
Showing
17 changed files
with
296 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/* fonts */ | ||
|
||
div.jqcloud { | ||
font-size: 120%; | ||
} | ||
|
||
@media (max-width: 800px) { | ||
div.jqcloud { | ||
font-size: 100%; | ||
} | ||
} | ||
|
||
div.jqcloud a { | ||
font-size: inherit; | ||
text-decoration: none; | ||
} | ||
|
||
div.jqcloud span.w10 { font-size: 300%; } | ||
div.jqcloud span.w9 { font-size: 280%; } | ||
div.jqcloud span.w8 { font-size: 260%; } | ||
div.jqcloud span.w7 { font-size: 240%; } | ||
div.jqcloud span.w6 { font-size: 220%; } | ||
div.jqcloud span.w5 { font-size: 200%; } | ||
div.jqcloud span.w4 { font-size: 180%; } | ||
div.jqcloud span.w3 { font-size: 140%; } | ||
div.jqcloud span.w2 { font-size: 120%; } | ||
div.jqcloud span.w1 { font-size: 100%; } | ||
|
||
/* colors */ | ||
|
||
div.jqcloud { color: var(--theme-link-colour); } | ||
div.jqcloud a { color: inherit; } | ||
|
||
div.jqcloud a:hover { filter: saturate(2); } | ||
div.jqcloud span.w10 { filter: saturate(1.3); } | ||
div.jqcloud span.w9 { filter: saturate(1.25); } | ||
div.jqcloud span.w8 { filter: saturate(1.2); } | ||
div.jqcloud span.w7 { filter: saturate(1.1); } | ||
div.jqcloud span.w6 { filter: saturate(1.0); } | ||
div.jqcloud span.w5 { filter: saturate(0.9); } | ||
div.jqcloud span.w4 { filter: saturate(0.85); } | ||
div.jqcloud span.w3 { filter: saturate(0.80); } | ||
div.jqcloud span.w2 { filter: saturate(0.75); } | ||
div.jqcloud span.w1 { filter: saturate(0.70); } | ||
|
||
/* layout */ | ||
|
||
div.jqcloud { | ||
overflow: hidden; | ||
position: relative; | ||
} | ||
|
||
div.jqcloud span { padding: 4px; } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,7 @@ | |
* Zookeeper Online | ||
* | ||
* @author Jim Mason <[email protected]> | ||
* @copyright Copyright (C) 1997-2023 Jim Mason <[email protected]> | ||
* @copyright Copyright (C) 1997-2024 Jim Mason <[email protected]> | ||
* @link https://zookeeper.ibinx.com/ | ||
* @license GPL-3.0 | ||
* | ||
|
@@ -47,6 +47,7 @@ interface IReview { | |
function getRecentReviews($user = "", $weeks = 0, $limit = 0, $loggedIn = 0); | ||
function getActiveReviewers($viewAll=0, $loggedIn=0); | ||
function getReviews($tag, $byName=1, $user = "", $loggedIn = 0, $byId = 0); | ||
function getTrending(int $limit = 50); | ||
function insertReview($tag, $private, $airname, $review, $user); | ||
function updateReview($tag, $private, $airname, $review, $user); | ||
function deleteReview($tag, $user); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,7 @@ | |
* Zookeeper Online | ||
* | ||
* @author Jim Mason <[email protected]> | ||
* @copyright Copyright (C) 1997-2023 Jim Mason <[email protected]> | ||
* @copyright Copyright (C) 1997-2024 Jim Mason <[email protected]> | ||
* @link https://zookeeper.ibinx.com/ | ||
* @license GPL-3.0 | ||
* | ||
|
@@ -156,8 +156,44 @@ public function getReviews($tag, $byName=1, $user = "", $loggedIn = 0, $byId = 0 | |
$stmt->bindValue(2, $user); | ||
return $stmt->executeAndFetchAll(\PDO::FETCH_BOTH); | ||
} | ||
|
||
public function getTrending(int $limit = 50) { | ||
$query = "SELECT hashtag, count(*) freq FROM reviews_hashtags " . | ||
"GROUP BY hashtag ORDER BY id DESC LIMIT ?"; | ||
$stmt = $this->prepare($query); | ||
$stmt->bindValue(1, $limit, \PDO::PARAM_INT); | ||
return $stmt->executeAndFetchAll(); | ||
} | ||
|
||
protected function syncHashtags(int $tag, string $user, ?string $review = null) { | ||
$this->adviseLock($tag); | ||
|
||
$query = "DELETE FROM reviews_hashtags WHERE tag = ? AND user = ?"; | ||
$stmt = $this->prepare($query); | ||
$stmt->bindValue(1, $tag); | ||
$stmt->bindValue(2, $user); | ||
$stmt->execute(); | ||
|
||
if($review && preg_match_all('/#(\pL\w*)/u', $review, $matches)) { | ||
$query = "INSERT INTO reviews_hashtags (tag, user, hashtag) VALUES (?, ?, ?)"; | ||
$stmt = $this->prepare($query); | ||
$stmt->bindValue(1, $tag); | ||
$stmt->bindValue(2, $user); | ||
$normalized = array_unique(array_map('strtolower', $matches[1])); | ||
$hashtags = array_intersect_key($matches[1], $normalized); | ||
foreach($hashtags as $hashtag) { | ||
$stmt->bindValue(3, $hashtag); | ||
$stmt->execute(); | ||
} | ||
} | ||
|
||
$this->adviseUnlock($tag); | ||
} | ||
|
||
public function insertReview($tag, $private, $airname, $review, $user) { | ||
// we must do this first, as caller depends on lastInsertId from INSERT | ||
$this->syncHashtags($tag, $user, $private ? null : $review); | ||
|
||
$query = "INSERT INTO reviews " . | ||
"(tag, user, created, private, review, airname) VALUES (" . | ||
"?, ?, " . | ||
|
@@ -171,7 +207,13 @@ public function insertReview($tag, $private, $airname, $review, $user) { | |
$stmt->bindValue(4, $review); | ||
if($airname) | ||
$stmt->bindValue(5, $airname); | ||
return $stmt->execute()?$stmt->rowCount():0; | ||
$count = $stmt->execute() ? $stmt->rowCount() : 0; | ||
|
||
// back out hashtags on failure | ||
if(!$count) | ||
$this->syncHashtags($tag, $user); | ||
|
||
return $count; | ||
} | ||
|
||
public function updateReview($tag, $private, $airname, $review, $user) { | ||
|
@@ -188,7 +230,12 @@ public function updateReview($tag, $private, $airname, $review, $user) { | |
$stmt->bindValue($p++, $review); | ||
$stmt->bindValue($p++, $tag); | ||
$stmt->bindValue($p++, $user); | ||
return $stmt->execute()?$stmt->rowCount():0; | ||
$count = $stmt->execute() ? $stmt->rowCount() : 0; | ||
|
||
if($count) | ||
$this->syncHashtags($tag, $user, $private ? null : $review); | ||
|
||
return $count; | ||
} | ||
|
||
public function deleteReview($tag, $user) { | ||
|
@@ -197,7 +244,13 @@ public function deleteReview($tag, $user) { | |
$stmt = $this->prepare($query); | ||
$stmt->bindValue(1, $tag); | ||
$stmt->bindValue(2, $user); | ||
return $stmt->execute()?$stmt->rowCount():0; | ||
$count = $stmt->execute() ? $stmt->rowCount() : 0; | ||
|
||
// delete any associated hashtags | ||
if($count) | ||
$this->syncHashtags($tag, $user); | ||
|
||
return $count; | ||
} | ||
|
||
public function setExportId($tag, $user, $exportId) { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.