add #sort=reverse, #44.

This commit is contained in:
Miroslav Šedivý 2023-01-24 18:02:48 +01:00
parent 1583120679
commit f17219d054
3 changed files with 11 additions and 4 deletions

View File

@ -208,9 +208,10 @@ To check if your server is set up correctly, turn on a debug mode (in config add
* Upload images using CTRL + V *(paste it into textarea)*.
* Highlight code in post using `[code]..your code..[/code]`.
* Highlight your goal using `[goal]Text of your goal.[/goal]`.
* Use tags in posts (allowed characters `A-Za-z0-9-_` terminated by space or EOL): `#song`
* Sort posts by hashtags: `http://blog/#tag=songs`
* Sort posts by location in url using: `http://blog/#loc=Vienna`.
* Use tags in posts (allowed characters `A-Za-z0-9-_` terminated by space or EOL): `#song`.
* Sort posts in reverse order (oldest first): `http://blog/#sort=reverse`.
* Filter posts by hashtags: `http://blog/#tag=songs`.
* Filter posts by location in url using: `http://blog/#loc=Vienna`.
* Display posts from chosen date using (format YYYY-MM-DD or YYY-MM): `http://blog/#from=2017-06`.
* Display posts to chosen date using (format YYYY-MM-DD or YYY-MM): `http://blog/#to=2017-06`.
* Combine parameters in url using `&`, e.g. show posts between dates: `http://blog/#from=2017-06&to=2017-08`.

View File

@ -449,7 +449,7 @@ class Post
($loc ? "`location` $like_match AND " : "").
($person ? "`persons` $like_match AND " : "").
"`status` <> 5
ORDER BY `posts`.`datetime` DESC
ORDER BY `posts`.`datetime` ".(@$r["sort"] == 'reverse' ? "ASC" : "DESC")."
LIMIT ? OFFSET ?
", $from, $to, $id, $tag, $loc, $person, $r["limit"], $r["offset"]
)->all();

View File

@ -13,6 +13,7 @@ var posts = {
limit: 5, // Limit posts per load
offset: 0, // Current offset
sort: "default", // Default is from newest to oldest posts (use reverse for oldest to newest)
filter: {
from: null, // Show posts from specified date
@ -34,6 +35,10 @@ var posts = {
// Update ID hash
location.hash.replace(/([a-z]+)\=([^\&]+)/g, function(_, key, value){
if (key == "sort") {
posts.sort = decodeURIComponent(value);
return;
}
posts.filter[key] = decodeURIComponent(value);
$(".more_posts").show();
});
@ -72,6 +77,7 @@ var posts = {
action: "load",
limit: posts.limit,
offset: posts.offset,
sort: posts.sort,
filter: posts.filter
},
success: function(posts_data){