@@ -0,0 +1,131 @@ | |||
[board-defaults] | |||
nuke-pass = changeme | |||
sql-table = changeme | |||
title = Wakarimasen image board | |||
showtitletxt = true | |||
showtitleimg = false | |||
titleimg = title.jpg | |||
favicon = wakaba.ico | |||
images-per-page = 10 | |||
replies-per-thread = 5 | |||
replies-per-sticky = 1 | |||
# Enable "Last xx Posts?" | |||
enable-abbreviated-thread-pages = false | |||
posts-in-abbreviated-thread-pages = 50 | |||
# Number of image replies per thread to show, set to 0 for no limit. | |||
image-replies-per-thread = 0 | |||
# Defines what to print if there is no text entered in the name/text/title fields | |||
no-name = Anonymous | |||
no-text = | |||
no-title = | |||
forced-anon = false | |||
# Title of the default style for the board. | |||
default-style = Futaba | |||
# Limitations | |||
max-upload-kb = 10240 # kb | |||
max-width = 200 # w | |||
max-height = 200 # h | |||
max-topic-bumps = 500 # res | |||
max-posts = 0 | |||
max-threads = 0 | |||
max-field-length = 100 | |||
max-comment-length = 8192 | |||
max-lines-shown = 15 | |||
max-image-width = 16384 | |||
max-image-height = 16384 | |||
max-image-pixels = 50000000 | |||
allow-textonly = false | |||
allow-images = true | |||
allow-text-replies = true | |||
allow-image-replies = true | |||
# Maximum age of a thread in hours (set to 0 to disable) | |||
max-age = 0 | |||
# Maximum size to use for all images in megabytes (set to 0 to disable) | |||
max-megabytes = 0 | |||
# How are duplicate files forbidden? ("board": board-wide, | |||
# "thread": current thread, or blank to disable duplicate detection) | |||
duplicate-detection = thread | |||
# Tweaks | |||
thumbnail-small = true | |||
thumbnail-quality = 60 | |||
# Thumbnail/image to show for deleted files (leave empty to show text message) | |||
deleted-thumbnail = | |||
deleted-image = | |||
# Allow unknown filetypes | |||
allow-unknown = false | |||
# Munge unknown file type extensions with this. If you remove this, make sure your web server is locked down properly. | |||
munge-unknown = .unknown | |||
# file extensions which are forbidden | |||
forbidden-extensions = php,php3,php4,phtml,shtml,cgi,pl,pm,py,r,exe,dll,scr,pif,asp,cfm,jsp,vbs | |||
# Floodcheck | |||
floodcheck-posts = 5 # renzoku1 | |||
floodcheck-image-posts = 10 # renzoku2 | |||
floodcheck-identical-posts = 900 # renzoku3 | |||
# Seconds that you can post to your own thread without increasing the sage count | |||
nosage-window = 1200 | |||
# Old images and posts are moved into an archive dir instead of deleted | |||
archive-mode = false | |||
# Character is displayed before tripcodes | |||
tripkey = ! | |||
# Enable WakabaMark formatting. | |||
enable-wakabamark = true | |||
# Approximate line length used by reply abbreviation code to guess at the length of a reply. | |||
approx-line-length = 150 | |||
# Bypass thumbnailing code and just use HTML to resize the image. STUPID, wastes bandwidth. | |||
stupid-thumbnailing = false | |||
# Path argument for cookies ('root': cookies apply to all boards on the site, 'current': cookies apply only to this board, 'parent': cookies apply to all boards in the parent directory) | |||
cookie-path = root | |||
# Enable the spam trap (empty, hidden form fields that spam bots usually fill out) | |||
spam-trap = true | |||
# Name of the board's style cookie. Generally a good idea to keep the same across all boards. | |||
style-cookie = wakastyle | |||
# Internal paths and files - might as well leave this alone. | |||
img-dir = src/ | |||
thumb-dir = thumb/ | |||
res-dir = res/ | |||
archive-dir = arch/ | |||
backup-dir = backup/ | |||
redir-dir = redir/ | |||
html-self = wakaba.html | |||
js-file = /wakaba3.js | |||
tmp-dir = tmp/ | |||
css-dir = ../include/common/css/ | |||
# Oekaki | |||
enable-oekaki = 0 | |||
oekaki-enable-modify = 1 | |||
oekaki-default-x = 300 | |||
oekaki-default-y = 300 | |||
oekaki-max-x = 800 | |||
oekaki-max-y = 800 | |||
oekaki-min-x = 100 | |||
oekaki-min-y = 100 | |||
oekaki-default-painter = shi-norm |
@@ -0,0 +1,146 @@ | |||
[wakarimasen] | |||
# Admin password. For fucks's sake, change this. | |||
admin-pass = changeme | |||
# Cryptographic secret. CHANGE THIS to something totally random, and long. | |||
secret = changeme | |||
# DB engine configuration for mysql | |||
#sql_engine = mysql:///username:password@localhost/database | |||
# DB engine configuration for sqlite (requires disabling pooling) | |||
sql-engine = sqlite:///wakarimasen.sqlite | |||
sql-pooling = false | |||
sql-pool-size = 100 | |||
sql-pool-max-overflow = 10 | |||
# Root of board cache relative to document root. | |||
board-dir = | |||
# What's the name of this server? | |||
server-name = localhost | |||
# Debug | |||
debug = false | |||
# File extension for all board pages. | |||
page-ext = .html | |||
# Charset. | |||
charset = utf-8 | |||
# Use HTTPS for admin logins. | |||
use-secure-admin = true | |||
# Use tempfiles when creating pages | |||
use-tempfiles = true | |||
# List of spam filter rules | |||
spam-files = spam.txt | |||
# Path to apache .htaccess for bans | |||
htaccess-path = ./ | |||
# Date style ('futaba', '2ch', 'localtime', 'tiny') | |||
date-style = futaba | |||
# Use alternate redirect method. (Javascript/meta-refresh instead of HTTP forwards. Needed to run on certain servers, like IIS.) | |||
# >implying we support IIS | |||
alternate-redirect = false | |||
# Time offset in seconds, for display on board pages. You can use this to adjust board time to your local time! | |||
time-offset = 0 | |||
home = / | |||
# Relative url to wakaba js file | |||
js-file = wakaba3.js | |||
[imagemagick] | |||
# Location of the ImageMagick convert command | |||
# (usually just 'convert'/'identify', but sometimes a full path is needed) | |||
convert-command = convert | |||
# Same as above, for identify | |||
identify-command = identify | |||
fg-anim-color = white | |||
bg-anim-color = #660066 | |||
[admin] | |||
# How long should staff log entries be retained? (Days) | |||
staff-log-retention = 60 | |||
# How long should report entries be retained? (Days) | |||
report-retention = 30 | |||
report-comment-max-length = 250 | |||
report-renzoku = 60 | |||
# Number of times a user may fail a password prompt prior to banning. | |||
passfail-threshold = 5 | |||
# How long a failed password prompt is held against a host (Hours) | |||
passfail-rollback = 24 | |||
# How long password prompts last before timing out and counting against the user. | |||
passprompt-expire-to-failure = 300 | |||
# Back up posts that are deleted or edited? | |||
post-backup = true | |||
# How long should backups last prior to purging? (Days) | |||
post-backup-expire = 14 | |||
# Enable proxy checking | |||
enable-proxy-check = true | |||
proxy-command = | |||
# How long to keep proxies in either white or black lists? (Days) | |||
proxy-white-age = 14 | |||
proxy-black-age = 14 | |||
[rss] | |||
enable = true | |||
# Number of items in each feed | |||
rss-length = 10 | |||
# Webmaster email address and name. Example format should be preserved for RSS spec. | |||
rss-webmaster = webmaster@example.com (Name) | |||
[hcaptcha] | |||
enable = false | |||
question = desu | |||
answer = desu | |||
cookie-bypass = true | |||
nokosage-bypass = true | |||
[sql-tables] | |||
# should be self-explanatory | |||
backup = __waka_backup | |||
admin = admin | |||
proxy = proxy | |||
report = reports | |||
account = staff_accounts | |||
stafflog = staff_activity | |||
common_site = board_index | |||
passprompt = passprompt | |||
passfail = passfail | |||
[icons] | |||
x-base-url = /include/boards/icons/ | |||
#mp3 = audio-mp3.png | |||
#ogg = audio-ogg.png | |||
#etc |
@@ -0,0 +1,160 @@ | |||
''' | |||
Script usage: | |||
python migrate_config.py (global|board) <input.py> | |||
Examples: | |||
python migrate_config.py global config.py | |||
...will read the config.py file from the current directory and output | |||
the translated ini file to stdout | |||
python migrate_config.py board desu/board_config.py | |||
...will do the same for a board config. | |||
This script depends on the default ini configs to do the name mappings, | |||
the "util" and "config_defaults" wakarimasen modules, and | |||
base_board/board_config.py. | |||
''' | |||
import os | |||
import sys | |||
from ConfigParser import ConfigParser | |||
import util | |||
def run_mapping(cp, config_keys, manual_map): | |||
mapping = [] | |||
unmapped = [] | |||
for section in cp.sections(): | |||
for option in cp.options(section): | |||
if (section, option) in manual_map: | |||
manual_name = manual_map[(section, option)] | |||
mapping.append((section, option, manual_name)) | |||
continue | |||
if section == 'hcaptcha': | |||
old_name = "HCAPTCHA_" + option.upper().replace("-", "_") | |||
elif section == 'sql-tables': | |||
old_name = 'SQL_%s_TABLE' % option.upper() | |||
else: | |||
old_name = option.upper().replace("-", "_") | |||
if old_name in config_keys: | |||
mapping.append((section, option, old_name)) | |||
else: | |||
unmapped.append((section, option)) | |||
return (mapping, unmapped) | |||
def print_mapping(mapping): | |||
for k,v in sorted(mapping.items(), key=lambda x:x[1]): | |||
print k, "\t", v | |||
def map_global_config(): | |||
cp = ConfigParser() | |||
cp.read("config.defaults.ini") | |||
config_keys = dir(__import__('config_defaults')) | |||
manual_map = { | |||
('hcaptcha', 'enable'): 'HCAPTCHA', | |||
('rss', 'enable'): 'ENABLE_RSS', | |||
('wakarimasen', 'admin-pass'): 'ADMIN_PASS', | |||
('wakarimasen', 'secret'): 'SECRET', | |||
('wakarimasen', 'sql-engine'): 'SQL_ENGINE', | |||
} | |||
return run_mapping(cp, config_keys, manual_map) | |||
def map_board_config(): | |||
cp = ConfigParser() | |||
cp.read("config.boards.defaults.ini") | |||
module = util.import2('board_config', "base_board") | |||
config_keys = module.config.keys() | |||
manual_map_pre = { | |||
'max-upload-kb': 'MAX_KB', | |||
'max-width': 'MAX_W', | |||
'max-height': 'MAX_H', | |||
'max-topic-bumps': 'MAX_RES', | |||
'no-name': 'S_ANONAME', | |||
'no-text': 'S_ANOTEXT', | |||
'no-title': 'S_ANOTITLE', | |||
'floodcheck-posts': 'RENZOKU', | |||
'floodcheck-image-posts': 'RENZOKU2', | |||
'floodcheck-identical-posts': 'RENZOKU3', | |||
} | |||
manual_map = dict([(('board-defaults', k), v) | |||
for (k, v) in manual_map_pre.items()]) | |||
return run_mapping(cp, config_keys, manual_map) | |||
def write_new_config(mode, module_name): | |||
path_name = "." | |||
if module_name.count("."): | |||
module_name = module_name.rsplit(".", 1)[0] | |||
if module_name.count("/"): | |||
path_name = os.path.dirname(module_name) | |||
module_name = os.path.basename(module_name) | |||
mapped, unmapped = map_global_config() if (mode == 'global') \ | |||
else map_board_config() | |||
module = util.import2(module_name, path_name) | |||
if mode == 'global': | |||
keygetter = lambda key: getattr(module, key, None) | |||
else: | |||
keygetter = lambda key: module.config.get(key, None) | |||
cp = ConfigParser() | |||
for section, option, key in mapped: | |||
got = keygetter(key) | |||
if not got: | |||
continue | |||
if not cp.has_section(section): | |||
cp.add_section(section) | |||
cp.set(section, option, got) | |||
if mode == 'global': | |||
icons = keygetter('ICONS') | |||
if icons: | |||
if not cp.has_section('icons'): | |||
cp.add_section('icons') | |||
icon_paths = icons.values() | |||
base_url = os.path.commonprefix(icon_paths) | |||
cp.set('icons', 'x-base-url', base_url) | |||
for ext, url in icons.iteritems(): | |||
cp.set('icons', ext, url[len(base_url):]) | |||
cp.write(sys.stdout) | |||
def main(): | |||
if len(sys.argv) < 3: | |||
print "Usage: migrate_config.py (global|board) <input.py>" | |||
return | |||
mode = sys.argv[1] | |||
module_name = sys.argv[2] | |||
if mode not in ('global', 'board'): | |||
print "Mode must be either 'global' or 'board'" | |||
return | |||
write_new_config(mode, module_name) | |||
if __name__ == '__main__': | |||
main() |