bibliogram/src/lib/constants.js

312 lines
11 KiB
JavaScript
Raw Normal View History

2020-01-28 03:14:21 +00:00
/*
Welcome to the constants file!
Copy a key and provide a new value in /config.js to override the value here.
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",
// 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
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.
// 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"},
{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-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,
replaceEmptyWithDefault: true
},{
name: "rewrite_twitter",
default: "",
boolean: false,
replaceEmptyWithDefault: true
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,
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,
self_blocked_status: {
2020-05-05 16:00:53 +00:00
enabled: true,
time: 2*60*60*1000,
},
2020-02-01 04:44:40 +00:00
db_user_id: true,
db_post_n3: true,
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]",
shortcode_regex: "[\\w-]+",
2020-04-12 14:52:04 +00:00
hashtag_regex: "[^ \\n`~!@#\\$%^&*()\\-=+[\\]{};:\"',<.>/?\\\\]+",
reserved_paths: [ // https://github.com/cloudrac3r/bibliogram/wiki/Reserved-URLs
// 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: {
instances_wiki_raw: "https://raw.githubusercontent.com/wiki/cloudrac3r/bibliogram/Instances.md"
},
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: {
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"),
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"),
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: [],
database_version: 9
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