Updated the data reading to have a data request limit, also updated docs

on new configuration options
This commit is contained in:
2025-11-27 11:44:27 +00:00
parent 7d38752f34
commit 54b6f018cf
3 changed files with 8 additions and 3 deletions

View File

@@ -16,10 +16,12 @@ All options show an example configuartion value and the variable type + an expla
| root_path | "/path/to/root/of/website" | String | Anything in this directory will be in the webroot, so put favicon.ico and anything else here. | | root_path | "/path/to/root/of/website" | String | Anything in this directory will be in the webroot, so put favicon.ico and anything else here. |
| data_storage | "json" | String | JSON is currently the only supported format, but SQL is going to be added/is a work in progress | | data_storage | "json" | String | JSON is currently the only supported format, but SQL is going to be added/is a work in progress |
| cache_data | true | Boolean | Not caching data means you can edit the posts, users, comments etc, maunally and not have to restart the server, however, for large instances this is not reccomended as it takes longer to load the required data. Note: config.json always needs a restart | | cache_data | true | Boolean | Not caching data means you can edit the posts, users, comments etc, maunally and not have to restart the server, however, for large instances this is not reccomended as it takes longer to load the required data. Note: config.json always needs a restart |
| request_data_limit | 20 | Integer | The maximum number of objects to return (latest), so if set to 20, then only the 20 most recent posts will ever show |
| root_path | '/var/www/blog_root' | String | Relative or Absolute path to the root directory of your static content, holds files such as favicon.ico, custom.css and robots.txt |
## Basic Customisation ## Basic Customisation
| name | example value | variable type | explanation | | name | example value | variable type | explanation |
|-----------------|----------------------------|---------------|------------------------------------------------------------------------------------------------------------------------------------------------------------| |-----------------|----------------------------|---------------|------------------------------------------------------------------------------------------------------------------------------------------------------------|
|locale|"en-GB"|String|Your locale, see [/locales](/locales) for a list of all locales (you can open a PR for a new translation too)| |locale|"en-US"|String|Your locale, see [/locales](/locales) for a list of all locales (you can open a PR for a new translation too)|
|seperator|"\<hr/\>"|String|By default, this will go inbetween posts and generally to seperate out content on pages.| |seperator|"\<hr/\>"|String|By default, this will go inbetween posts and generally to seperate out content on pages.|
|site_name|"Pete's Blogging Site!"|String|It's the name of your blog site, a human readable string.| |site_name|"Pete's Blogging Site!"|String|It's the name of your blog site, a human readable string.|
|site_description|"Read my blogs!"|String|This is what %W represents; it's the description of your instance, a human readable string.| |site_description|"Read my blogs!"|String|This is what %W represents; it's the description of your instance, a human readable string.|

View File

@@ -9,7 +9,7 @@
"cache_data": false, "cache_data": false,
"allow_signup": true, "allow_signup": true,
"site_description": "Read my blogs!", "site_description": "Read my blogs!",
"timeline_length": 20, "request_data_limit": 20,
"enable_hitcount": true, "enable_hitcount": true,
"charset": "UTF-8", "charset": "UTF-8",
"root_path": "../webroot/", "root_path": "../webroot/",

View File

@@ -78,10 +78,13 @@ export function getdata(data_type, key=-1, value=-1) {
case 'comments': case 'comments':
result = func.require_module(`../data/${data_type}.json`) result = func.require_module(`../data/${data_type}.json`)
if (key != -1) { if (key != -1) {
if (key == 'id' && value < result.length) { // id is the index
return result[value]
}
return result[func.find_key_value_pair(result, key, value)] return result[func.find_key_value_pair(result, key, value)]
return -1 // This index doesn't exist return -1 // This index doesn't exist
} }
return result return result.slice(- config['data_request_limit'])
break; break;
case 'hitcount': case 'hitcount':
result = func.require_module('../data/data.json') // This file is actually called data.json result = func.require_module('../data/data.json') // This file is actually called data.json