2020-01-28 03:14:21 +00:00
/ *
Welcome to the constants file !
Copy a key and provide a new value in / c o n f i g . j s t o o v e r r i d e t h e v a l u e h e r e .
Please read the comments above every section !
* /
2020-01-12 12:50:21 +00:00
2020-01-28 03:14:21 +00:00
let constants = {
// Things that server owners _should_ change!
2020-03-24 03:15:04 +00:00
// Protocol and domain that the website can be accessed on. Images and links in RSS feeds start with this URL.
// Do NOT include a trailing slash. If you leave this as localhost, Bibliogram will not work correctly when accessed from any other device.
// If you are using nginx to make Bibliogram accessible on port 80/443, do NOT write a port here.
// For example, "https://bibliogram.art"
website _origin : "http://localhost:10407" ,
2020-04-17 12:18:58 +00:00
// IP address to bind to.
// "0.0.0.0" will make the server reachable on all IPv4 interfaces.
// "::" will make the server reachable on all IPv6 interfaces, and maybe also IPv4. (https://nodejs.org/api/net.html#net_server_listen_port_host_backlog_callback)
// If you run nginx, you must change the nginx config instead.
bind _ip : "0.0.0.0" ,
2020-03-24 03:15:04 +00:00
// Port to actually run the webserver on.
port : 10407 ,
// You MUST read /src/site/pug/privacy.pug.template before changing has_privacy_policy!
has _privacy _policy : false ,
2020-06-19 05:45:51 +00:00
// If your instance is also available as an onion site, add the onion URL here.
// It should look something like "http://3gldbgtv5e4god56.onion" (no trailing slash).
2020-06-19 05:49:11 +00:00
onion _location : null ,
2020-01-28 03:14:21 +00:00
// Things that server owners _could_ change if they want to.
2020-02-02 13:24:14 +00:00
tor : {
enabled : false , // If false, everything else in this block has no effect.
password : null , // If `null`, Bibliogram will run its own Tor process instead.
for : {
user _html : false , // User HTML page seems to have less forgiving rates, and Tor always fails, so it's disabled by default.
timeline _graphql : true ,
post _graphql : true ,
reel _graphql : true
}
} ,
2020-03-15 06:50:29 +00:00
request _backend : "node-fetch" , // one of: "node-fetch", "got"
2020-03-03 12:32:09 +00:00
// After setting your privacy policy, I suggest you read src/site/html/.well-known/dnt-policy.txt. If you comply with it,
// change this to `true` to serve it, which will make extensions like Privacy Badger automatically whitelist the domain.
does _not _track : false ,
2020-02-02 13:24:14 +00:00
2020-02-18 04:06:11 +00:00
allow _user _from _reel : "preferForRSS" , // one of: "never", "fallback", "prefer", "onlyPreferSaved", "preferForRSS"
2020-02-02 13:24:14 +00:00
2020-04-22 11:59:45 +00:00
feeds : {
// Whether feeds are enabled.
enabled : true ,
// Whether to display links to feeds on pages.
display _links : true ,
// Whether to display the `v!` link to validate a feed.
display _validation _links : false ,
// This feed message field allows you to insert a custom message into all RSS feeds to inform users of important changes,
// such as feeds being disabled forever on that instance.
feed _message : {
enabled : false ,
// If the feed message is enabled, then `id` MUST be supplied.
// Please set it to `bibliogram:feed_announcement/your.domain/1`
// replacing `your.domain` with the address of your own domain,
// and incrementing `1` every time you make a new announcement (to make sure the IDs are unique).
id : "" ,
// The timestamp that you disabled feeds at. For example, if you disabled feeds forever starting at 2020-04-01T12:00:00 UTC,
// you should set this to 1585742400000.
timestamp : 0 ,
// The title of the feed item.
title : "Important message from Bibliogram" ,
// The text of the message.
message : "There is an important message about feeds on this Bibliogram instance. Please visit this link to read the message: " ,
// The link address.
link : "https://your.domain/feedannouncement"
} ,
feed _disabled _max _age : 2 * 24 * 60 * 60 // 2 days
} ,
2020-05-10 11:58:05 +00:00
// Themes. `file` is the filename without extension. `name` is the display name on the settings page.
2020-05-09 11:37:56 +00:00
// If you make your own theme, I encourage you to submit a pull request for it!
2020-05-10 11:58:05 +00:00
themes : {
// If you want to disable some official themes, then create an entry that replaces this array in config.js.
// Format: `{file: string, name: string}[]`
official : [
2020-05-15 13:25:06 +00:00
{ file : "classic" , name : "Vanilla sard" } ,
{ file : "blue" , name : "Vanilla sky" } ,
2020-06-02 14:52:58 +00:00
{ file : "discord" , name : "Discord dark" } ,
2020-06-16 11:02:21 +00:00
{ file : "pitchblack" , name : "Pitch black" } ,
2020-05-15 16:40:57 +00:00
{ file : "pussthecat.org" , name : "PussTheCat.org dark v1" } ,
2020-06-16 11:02:21 +00:00
{ file : "pussthecat.org-v2" , name : "PussTheCat.org dark v2" } ,
2020-05-10 11:58:05 +00:00
] ,
// To add your own theme, create an entry that replaces this array in config.js, then add your theme to it.
// Format: `{file: string, name: string}[]`
custom : [
] ,
// If you want your custom theme to be the default for your instance, don't forget to set it here!
// For good UI, you probably also want the default entry to be the first thing in the selection box.
default : "classic" ,
// This sets which order the themes appear in in the list on the settings page.
sort : {
// This sets whether the order is custom + official, or official + custom
order : "custom_first" , // "custom_first", "official_first"
// To selectively override that order, add things to this array.
// If you set it to `["blue", "midnight"]` then the theme with file name `blue` will be hoisted to the top,
// the theme with file name `midnight` will be below it, and all other themes will appear below those.
// Format: `string[]`
manual : [ ]
} ,
// These arrays should be empty, do not edit them!
collated : [ ] ,
collatedFiles : [ ]
} ,
2020-05-09 11:37:56 +00:00
2020-06-21 14:04:15 +00:00
default _user _settings : {
2020-07-19 13:40:27 +00:00
language : "en" ,
2020-06-21 14:04:15 +00:00
rewrite _youtube : "invidio.us" ,
rewrite _twitter : "nitter.net"
} ,
2020-07-22 12:58:21 +00:00
quota : {
enabled : false ,
timeframe : 20 * 60 * 60 * 1000 ,
count : 50 ,
ip _mode : "header" , // one of: "header", "address"
2020-07-22 13:20:06 +00:00
ip _header : "x-forwarded-for" ,
track : false
2020-07-22 12:58:21 +00:00
} ,
2020-05-04 15:06:07 +00:00
user _settings : [
{
name : "language" ,
2020-05-05 13:50:01 +00:00
default : "en" ,
2020-05-04 15:06:07 +00:00
boolean : false ,
replaceEmptyWithDefault : true // set this to false if the control is a checkbox and is not disabled
} , {
name : "show_comments" ,
default : "" ,
boolean : true ,
replaceEmptyWithDefault : true
2020-05-30 11:04:06 +00:00
} , {
name : "remove_trailing_hashtags" ,
default : "" ,
boolean : true ,
replaceEmptyWithDefault : false
2020-05-04 15:06:07 +00:00
} , {
name : "link_hashtags" ,
default : "" ,
boolean : true ,
replaceEmptyWithDefault : true
} , {
name : "spa" ,
default : "on" ,
boolean : true ,
2020-05-05 14:14:11 +00:00
replaceEmptyWithDefault : false
2020-05-30 11:04:06 +00:00
} , {
name : "infinite_scroll" ,
default : "normal" ,
boolean : false ,
replaceEmptyWithDefault : true
2020-05-04 15:06:07 +00:00
} , {
name : "caption_side" ,
2020-05-05 13:50:01 +00:00
default : "left" ,
2020-05-04 15:06:07 +00:00
boolean : false ,
replaceEmptyWithDefault : true
} , {
name : "display_alt" ,
default : "" ,
boolean : true ,
replaceEmptyWithDefault : true
2020-05-05 15:35:18 +00:00
} , {
name : "timeline_columns" ,
default : "dynamic" ,
boolean : false ,
replaceEmptyWithDefault : true
} , {
name : "display_top_nav" ,
default : "" ,
boolean : true ,
replaceEmptyWithDefault : true
2020-05-09 09:34:00 +00:00
} , {
name : "save_data" ,
default : "automatic" ,
boolean : false ,
replaceEmptyWithDefault : true
} , {
name : "rewrite_youtube" ,
default : "" ,
boolean : false ,
2020-06-21 14:04:15 +00:00
replaceEmptyWithDefault : false
2020-05-09 09:34:00 +00:00
} , {
name : "rewrite_twitter" ,
default : "" ,
boolean : false ,
2020-06-21 14:04:15 +00:00
replaceEmptyWithDefault : false
2020-05-04 15:06:07 +00:00
}
] ,
2020-05-29 10:44:58 +00:00
featured _profiles : [
] ,
2020-04-12 14:52:04 +00:00
use _assistant : {
2020-04-07 06:30:00 +00:00
enabled : false ,
2020-04-12 14:52:04 +00:00
assistants : [
2020-04-07 06:30:00 +00:00
] ,
offline _request _cooldown : 20 * 60 * 1000 ,
2020-05-10 07:19:17 +00:00
blocked _request _cooldown : 0
2020-04-07 06:30:00 +00:00
} ,
2020-04-12 14:52:04 +00:00
as _assistant : {
enabled : false , // You can still start just the assistant with npm run assistant.
require _key : false ,
// List of keys that are allowed access. You can use any string.
// Try `crypto.randomBytes(20).toString("hex")` to get some randomness.
keys : [ ]
} ,
2020-01-28 03:14:21 +00:00
caching : {
image _cache _control : ` public, max-age= ${ 7 * 24 * 60 * 60 } ` ,
2020-01-28 11:38:05 +00:00
resource _cache _time : 30 * 60 * 1000 ,
2020-02-01 04:44:40 +00:00
instance _list _cache _time : 3 * 60 * 1000 ,
2020-03-18 08:14:12 +00:00
cache _sweep _interval : 3 * 60 * 1000 ,
2020-05-09 15:20:13 +00:00
csrf _time : 60 * 60 * 1000 ,
2020-04-16 13:40:20 +00:00
self _blocked _status : {
2020-05-05 16:00:53 +00:00
enabled : true ,
2020-04-16 13:40:20 +00:00
time : 2 * 60 * 60 * 1000 ,
} ,
2020-02-01 04:44:40 +00:00
db _user _id : true ,
2020-06-25 11:47:16 +00:00
db _post _n3 : false ,
2020-04-16 13:14:27 +00:00
db _request _history : false
2020-01-28 03:14:21 +00:00
} ,
// Instagram uses this stuff. This shouldn't be changed, except to fix a bug that hasn't yet been fixed upstream.
2020-01-12 12:50:21 +00:00
external : {
2020-02-02 13:24:14 +00:00
reel _query _hash : "c9100bf9110dd6361671f113dd02e7d6" ,
2020-01-12 12:50:21 +00:00
timeline _query _hash : "e769aa130647d2354c40ea6a439bfc08" ,
2020-02-02 11:43:56 +00:00
timeline _query _hash _2 : "42323d64886122307be10013ad2dcc44" , // https://github.com/rarcega/instagram-scraper/blob/dc022081dbefc81500c5f70cce5c70cfd2816e3c/instagram_scraper/constants.py#L30
2020-01-18 15:38:14 +00:00
shortcode _query _hash : "2b0673e0dc4580674a88d426fe00ea90" ,
2020-05-29 08:45:13 +00:00
igtv _query _hash : "bc78b344a68ed16dd5d7f264681c4c76" ,
2020-01-14 14:38:33 +00:00
timeline _fetch _first : 12 ,
2020-05-29 08:45:13 +00:00
igtv _fetch _first : 12 ,
2020-02-21 12:32:57 +00:00
username _regex : "[\\w.]*[\\w]" ,
2020-02-03 14:30:19 +00:00
shortcode _regex : "[\\w-]+" ,
2020-04-12 14:52:04 +00:00
hashtag _regex : "[^ \\n`~!@#\\$%^&*()\\-=+[\\]{};:\"',<.>/?\\\\]+" ,
2020-07-16 12:19:37 +00:00
reserved _paths : [ // https://git.sr.ht/~cadence/bibliogram-docs/tree/master/docs/Reserved%20URLs.md
2020-04-12 14:52:04 +00:00
// Redirects
"about" , "explore" , "support" , "press" , "api" , "privacy" , "safety" , "admin" ,
// Content
"embed.js" ,
// Not found, but likely reserved
"graphql" , "accounts" , "p" , "help" , "terms" , "contact" , "blog" , "igtv"
]
2020-01-12 12:50:21 +00:00
} ,
2020-01-28 11:38:05 +00:00
resources : {
2020-07-13 13:27:42 +00:00
instances _wiki _raw : "https://git.sr.ht/~cadence/bibliogram-docs/blob/master/docs/Instances.md" ,
2020-07-07 10:08:19 +00:00
saved _requests _location : "https://meta.bibliogram.art/saved_requests/"
2020-01-28 11:38:05 +00:00
} ,
2020-01-28 03:14:21 +00:00
// My code uses this stuff. Server owners have no reason to change it.
2020-01-12 12:50:21 +00:00
symbols : {
2020-01-26 14:56:59 +00:00
NO _MORE _PAGES : Symbol ( "NO_MORE_PAGES" ) ,
TYPE _IMAGE : Symbol ( "TYPE_IMAGE" ) ,
TYPE _VIDEO : Symbol ( "TYPE_VIDEO" ) ,
TYPE _GALLERY : Symbol ( "TYPE_GALLERY" ) ,
TYPE _GALLERY _IMAGE : Symbol ( "TYPE_GALLERY_IMAGE" ) ,
2020-01-27 06:03:28 +00:00
TYPE _GALLERY _VIDEO : Symbol ( "TYPE_GALLERY_VIDEO" ) ,
NOT _FOUND : Symbol ( "NOT_FOUND" ) ,
2020-02-02 11:43:56 +00:00
INSTAGRAM _DEMANDS _LOGIN : Symbol ( "INSTAGRAM_DEMANDS_LOGIN" ) ,
2020-02-05 12:32:51 +00:00
RATE _LIMITED : Symbol ( "RATE_LIMITED" ) ,
2020-04-07 06:30:00 +00:00
ENDPOINT _OVERRIDDEN : Symbol ( "ENDPOINT_OVERRIDDEN" ) ,
NO _ASSISTANTS _AVAILABLE : Symbol ( "NO_ASSISTANTS_AVAILABLE" ) ,
2020-07-22 12:58:21 +00:00
QUOTA _REACHED : Symbol ( "QUOTA_REACHED" ) ,
2020-04-13 15:46:23 +00:00
extractor _results : {
SUCCESS : Symbol ( "SUCCESS" ) ,
AGE _RESTRICTED : Symbol ( "AGE_RESTRICTED" ) ,
NO _SHARED _DATA : Symbol ( "NO_SHARED_DATA" )
} ,
2020-04-07 06:30:00 +00:00
assistant _statuses : {
OFFLINE : Symbol ( "OFFLINE" ) ,
BLOCKED : Symbol ( "BLOCKED" ) ,
OK : Symbol ( "OK" ) ,
2020-04-12 14:52:04 +00:00
NONE : Symbol ( "NONE" ) ,
NOT _AUTHENTICATED : Symbol ( "NOT_AUTHENTICATED" )
} ,
fetch _context : {
RSS : Symbol ( "RSS" ) ,
ASSISTANT : Symbol ( "ASSISTANT" )
2020-04-07 06:30:00 +00:00
}
2020-02-01 04:44:40 +00:00
} ,
2020-05-29 08:45:13 +00:00
secrets : {
push _webhook _token : null
} ,
2020-04-22 11:59:45 +00:00
additional _routes : [ ] ,
2020-07-22 13:20:06 +00:00
database _version : 10 ,
actually _backup _on _database _upgrade : true
2020-01-12 12:50:21 +00:00
}
2020-01-28 03:14:21 +00:00
// Override values from config and export the result
const md = require ( "mixin-deep" )
2020-04-14 14:03:38 +00:00
if ( process . env . BIBLIOGRAM _CONFIG ) { // presence of environment variable BIBLIOGRAM_CONFIG overrides /config.js
const config = JSON . parse ( process . env . BIBLIOGRAM _CONFIG )
constants = md ( constants , config )
} else {
const config = require ( "../../config" )
constants = md ( constants , config )
}
2020-05-10 11:58:05 +00:00
// Set theme settings
constants . user _settings . push ( {
name : "theme" ,
default : constants . themes . default ,
boolean : false ,
replaceEmptyWithDefault : true
} )
let pool
if ( constants . themes . sort . order === "custom_first" ) {
pool = [ ] . concat ( constants . themes . custom , constants . themes . official )
} else if ( constants . themes . sort . order === "official_first" ) {
pool = [ ] . concat ( constants . themes . official , constants . themes . custom )
}
for ( const file of constants . themes . sort . manual ) {
const index = pool . findIndex ( row => row . file === file )
if ( index !== - 1 ) {
const removed = pool . splice ( index , 1 ) [ 0 ]
constants . themes . collated . push ( removed )
}
}
constants . themes . collated = constants . themes . collated . concat ( pool )
constants . themes . collatedFiles = constants . themes . collatedFiles . concat ( pool . map ( row => row . file ) )
2020-01-28 03:14:21 +00:00
module . exports = constants