diff --git a/configs/template.js.example b/configs/template.js.example index 0ffad0ae..1002da98 100644 --- a/configs/template.js.example +++ b/configs/template.js.example @@ -112,9 +112,10 @@ module.exports = { //max age of a hot thread, with a reducing score multiplier from 0-1 bias towards this date hotThreadsMaxAge: 2629800000, - //default url format/links for archive and reverse image search links, %s will be replaced by the url + //default url format/links for archive, reverse image search, and ethereum links, %s will be replaced by the url archiveLinksURL: 'https://archive.today/?run=1&url=%s', reverseImageLinksURL: 'https://tineye.com/search?url=%s', + ethereumLinksURL: 'https://etherscan.io/address/%s', //cache templates in memory. disable only if editing templates and doing dev work cacheTemplates: true, diff --git a/controllers/forms/globalsettings.js b/controllers/forms/globalsettings.js index e69837cb..ef7e52cb 100644 --- a/controllers/forms/globalsettings.js +++ b/controllers/forms/globalsettings.js @@ -15,7 +15,7 @@ module.exports = { paramConverter: paramConverter({ timeFields: ['hot_threads_max_age', 'inactive_account_time', 'default_ban_duration', 'block_bypass_expire_after_time', 'dnsbl_cache_time', 'board_defaults_delete_protection_age'], trimFields: ['captcha_options_grid_question', 'captcha_options_grid_trues', 'captcha_options_grid_falses', 'captcha_options_font', 'allowed_hosts', 'dnsbl_blacklists', 'other_mime_types', - 'highlight_options_language_subset', 'global_limits_custom_css_filters', 'board_defaults_filters', 'filters', 'archive_links', 'reverse_links', 'language', 'board_defaults_language'], + 'highlight_options_language_subset', 'global_limits_custom_css_filters', 'board_defaults_filters', 'filters', 'archive_links', 'ethereum_links', 'reverse_links', 'language', 'board_defaults_language'], numberFields: ['inactive_account_action', 'abandoned_board_action', 'auth_level', 'captcha_options_text_wave', 'captcha_options_text_paint', 'captcha_options_text_noise', 'captcha_options_grid_noise', 'captcha_options_grid_edge', 'captcha_options_generate_limit', 'captcha_options_grid_size', 'captcha_options_grid_image_size', 'captcha_options_num_distorts_min', 'captcha_options_num_distorts_max', 'captcha_options_distortion', 'captcha_options_grid_icon_y_offset', 'flood_timers_same_content_same_ip', 'flood_timers_same_content_any_ip', @@ -73,6 +73,12 @@ module.exports = { } return false; }, expected: true, error: __('Invalid reverse image search links URL format, must be a link containing %s where the url param belongs.') }, + { result: () => { + if (req.body.ethereum_links) { + return /https?\:\/\/[^\s<>\[\]{}|\\^]+%s[^\s<>\[\]{}|\\^]*/i.test(req.body.ethereum_links); + } + return false; + }, expected: true, error: __('Invalid ethereum links URL format, must be a link containing %s where the url param belongs.') }, { result: existsBody(req.body.referrer_check) ? lengthBody(req.body.allowed_hosts, 1) : false, expected: false, error: __('Please enter at least one allowed host in the "Allowed Hosts" field when the "Referer Check" option is selected.') }, { result: numberBody(req.body.inactive_account_time), expected: true, error: __('Invalid inactive account time') }, { result: numberBody(req.body.inactive_account_action, 0, 2), expected: true, error: __('Inactive account action must be a number from 0-2') }, diff --git a/gulpfile.js b/gulpfile.js index 63c55915..a834acee 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -424,6 +424,7 @@ async function custompages() { early404Fraction: config.get.early404Fraction, early404Replies: config.get.early404Replies, meta: config.get.meta, + ethereumLinksURL: config.get.ethereumLinksURL, archiveLinksURL: config.get.archiveLinksURL, reverseImageLinksURL: config.get.reverseImageLinksURL, enableWebring: config.get.enableWebring, diff --git a/lib/build/render.js b/lib/build/render.js index 5f88fdc2..2d3b9679 100644 --- a/lib/build/render.js +++ b/lib/build/render.js @@ -15,16 +15,17 @@ const { outputFile } = require('fs-extra') , i18n = require(__dirname+'/../locale/locale.js') , config = require(__dirname+'/../../lib/misc/config.js'); -let { language, archiveLinksURL, lockWait, globalLimits, boardDefaults, cacheTemplates, +let { language, archiveLinksURL, ethereumLinksURL, lockWait, globalLimits, boardDefaults, cacheTemplates, reverseImageLinksURL, meta, enableWebring, captchaOptions, globalAnnouncement, enableWeb3 } = config.get , renderLocals = null; const updateLocals = () => { - ({ language, archiveLinksURL, lockWait, globalLimits, boardDefaults, cacheTemplates, + ({ language, archiveLinksURL, ethereumLinksURL, lockWait, globalLimits, boardDefaults, cacheTemplates, reverseImageLinksURL, meta, enableWebring, captchaOptions, globalAnnouncement, enableWeb3 } = config.get); renderLocals = { Permissions, cache: cacheTemplates, + ethereumLinksURL, archiveLinksURL, reverseImageLinksURL, meta, diff --git a/lib/web3/web3.js b/lib/web3/web3.js index 1b309281..346223a7 100644 --- a/lib/web3/web3.js +++ b/lib/web3/web3.js @@ -1,7 +1,6 @@ 'use strict'; //NOTE: unused (for now) - const { Web3 } = require('web3') , config = require(__dirname+'/../misc/config.js') , { addCallback } = require(__dirname+'/../redis/redis.js') diff --git a/migrations/1.2.0.js b/migrations/1.2.0.js index c442ee1f..771073e9 100644 --- a/migrations/1.2.0.js +++ b/migrations/1.2.0.js @@ -8,6 +8,7 @@ module.exports = async(db, redis) => { 'globalLimits.filters': { max: 50, }, + 'ethereumLinksURL': 'https://etherscan.io/address/%s', }, }); diff --git a/models/forms/changeglobalsettings.js b/models/forms/changeglobalsettings.js index 97ea5e93..46ed4ad1 100644 --- a/models/forms/changeglobalsettings.js +++ b/models/forms/changeglobalsettings.js @@ -19,6 +19,7 @@ const { Boards } = require(__dirname+'/../../db/') 'meta.siteName': ['deletehtml', 'scripts', 'custompages'], 'meta.url': ['deletehtml', 'scripts', 'custompages'], 'archiveLinksURL': ['deletehtml', 'custompages'], + 'ethereumLinksURL': ['deletehtml', 'custompages'], 'reverseImageLinksURL': ['deletehtml', 'custompages'], 'enableWebring': ['deletehtml', 'custompages'], 'enableWeb3': ['deletehtml'], @@ -130,6 +131,7 @@ module.exports = async (req, res) => { allowCustomOverboard: booleanSetting(req.body.allow_custom_overboard, oldSettings.allowCustomOverboard), archiveLinksURL: trimSetting(req.body.archive_links, oldSettings.archiveLinksURL), reverseImageLinksURL: trimSetting(req.body.reverse_links, oldSettings.reverseImageLinksURL), + ethereumLinksURL: trimSetting(req.body.ethereum_links, oldSettings.ethereumLinksURL), cacheTemplates: booleanSetting(req.body.cache_templates, oldSettings.cacheTemplates), lockWait: numberSetting(req.body.lock_wait, oldSettings.lockWait), pruneModlogs: numberSetting(req.body.prune_modlogs, oldSettings.pruneModlogs), @@ -137,7 +139,7 @@ module.exports = async (req, res) => { pruneIps: numberSetting(req.body.prune_ips, oldSettings.pruneIps), enableWebring: booleanSetting(req.body.enable_webring, oldSettings.enableWebring), enableWeb3: booleanSetting(req.body.enable_web3, oldSettings.enableWeb3), - ethereumNode: trimSetting(req.body.ethereum_node, oldSettings.ethereumNode), + // ethereumNode: trimSetting(req.body.ethereum_node, oldSettings.ethereumNode), following: arraySetting(req.body.webring_following, oldSettings.following), blacklist: arraySetting(req.body.webring_blacklist, oldSettings.blacklist), logo: arraySetting(req.body.webring_logos, oldSettings.logo), diff --git a/server.js b/server.js index 0fc38a6c..21f3d35f 100644 --- a/server.js +++ b/server.js @@ -68,7 +68,7 @@ const config = require(__dirname+'/lib/misc/config.js') const loadAppLocals = () => { const { language, cacheTemplates, boardDefaults, globalLimits, captchaOptions, archiveLinksURL, - reverseImageLinksURL, meta, enableWebring, globalAnnouncement, enableWeb3 } = config.get; + reverseImageLinksURL, meta, enableWebring, globalAnnouncement, enableWeb3, ethereumLinksURL } = config.get; //cache loaded templates app.cache = {}; app[cacheTemplates === true ? 'enable' : 'disable']('view cache'); @@ -77,6 +77,7 @@ const config = require(__dirname+'/lib/misc/config.js') app.locals.defaultTheme = boardDefaults.theme; app.locals.defaultCodeTheme = boardDefaults.codeTheme; app.locals.globalLimits = globalLimits; + app.locals.ethereumLinksURL = ethereumLinksURL; app.locals.archiveLinksURL = archiveLinksURL; app.locals.reverseImageLinksURL = reverseImageLinksURL; app.locals.enableWebring = enableWebring; diff --git a/views/mixins/web3signature.pug b/views/mixins/web3signature.pug index b34d5cd8..970774ab 100644 --- a/views/mixins/web3signature.pug +++ b/views/mixins/web3signature.pug @@ -1,3 +1,5 @@ mixin web3signature(signature, address) - .web3-address #{__('Address: %s', address)} - .web3-signature #{__('Signature: %s', signature)} + a.web3-address(href=ethereumLinksURL.replace('%s', encodeURIComponent(address)) rel='nofollow' referrerpolicy='same-origin' target='_blank') #{address.substring(0,5)}…#{address.substring(38, 42)} + details + summary #{__('Signature')} + .web3-signature #{signature} diff --git a/views/pages/globalmanagesettings.pug b/views/pages/globalmanagesettings.pug index ffc1de4d..57e6cff3 100644 --- a/views/pages/globalmanagesettings.pug +++ b/views/pages/globalmanagesettings.pug @@ -534,6 +534,15 @@ block content label.postform-style.ph-5 input(type='checkbox', name='enable_web3' value='true' checked=settings.enableWeb3) .row + .label + | #{__('Ethereum Links URL')} + | + small + | ( + a(href='/faq.html#archive-reverse-url-format') ? + | ) + input(type='text', name='ethereum_links', value=settings.ethereumLinksURL) + //- .row .label | #{__('Ethereum Node')} |