forked from moinwiki/moin
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
mass changes generated by ruff when updating moin/config/wikiconfig.py
changed single quotes to douple quotes, wrapped long import statements,
- Loading branch information
1 parent
722805a
commit f3913b7
Showing
1 changed file
with
76 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,56 +34,61 @@ | |
from moin.config.default import DefaultConfig | ||
from moin.utils.interwiki import InterWikiMap | ||
from moin.storage import create_mapping | ||
from moin.constants.namespaces import NAMESPACE_DEFAULT, NAMESPACE_USERPROFILES,NAMESPACE_USERS, \ | ||
NAMESPACE_HELP_COMMON, NAMESPACE_HELP_EN, NAMESPACE_ALL | ||
from moin.constants.namespaces import ( | ||
NAMESPACE_DEFAULT, | ||
NAMESPACE_USERPROFILES, | ||
NAMESPACE_USERS, | ||
NAMESPACE_HELP_COMMON, | ||
NAMESPACE_HELP_EN, | ||
) | ||
|
||
|
||
class Config(DefaultConfig): | ||
|
||
# These paths are usually correct. | ||
# See https://moin-20.readthedocs.io/en/latest/admin/configure.html#directory-structure | ||
wikiconfig_dir = os.path.abspath(os.path.dirname(__file__)) | ||
instance_dir = os.path.join(wikiconfig_dir, 'wiki') | ||
data_dir = os.path.join(instance_dir, 'data') | ||
index_storage = 'FileStorage', (os.path.join(instance_dir, "index"), ), {} | ||
instance_dir = os.path.join(wikiconfig_dir, "wiki") | ||
data_dir = os.path.join(instance_dir, "data") | ||
index_storage = "FileStorage", (os.path.join(instance_dir, "index"),), {} | ||
|
||
# setup moin to serve static files' or change to have your webserver serve static files | ||
serve_files = dict( | ||
wiki_local=os.path.join(wikiconfig_dir, 'wiki_local'), # store custom logos, CSS, templates, etc. here | ||
wiki_local=os.path.join(wikiconfig_dir, "wiki_local") # store custom logos, CSS, templates, etc. here | ||
) | ||
docs = os.path.join(wikiconfig_dir, 'docs', '_build', 'html') | ||
docs = os.path.join(wikiconfig_dir, "docs", "_build", "html") | ||
if os.path.isdir(docs): | ||
serve_files['docs'] = docs | ||
serve_files["docs"] = docs | ||
else: | ||
# change target if a specific release or language is available | ||
serve_files['external_docs'] = "https://moin-20.readthedocs.io/en/latest/" | ||
serve_files["external_docs"] = "https://moin-20.readthedocs.io/en/latest/" | ||
|
||
# copy templates/snippets.html to directory below and edit per requirements to customize logos, etc. | ||
template_dirs = [os.path.join(wikiconfig_dir, 'wiki_local'), ] | ||
template_dirs = [os.path.join(wikiconfig_dir, "wiki_local")] | ||
|
||
# it is required that you set interwikiname to a unique, stable and non-empty name. | ||
# Changing interwikiname on an existing wiki requires rebuilding the index. | ||
# moin index-destroy; moin index-create; moin index-rebuild | ||
interwikiname = 'MyMoinMoin' | ||
interwikiname = "MyMoinMoin" | ||
# load the interwiki map from intermap.txt | ||
try: | ||
interwiki_map = InterWikiMap.from_file(os.path.join(wikiconfig_dir, 'intermap.txt')).iwmap | ||
interwiki_map = InterWikiMap.from_file(os.path.join(wikiconfig_dir, "intermap.txt")).iwmap | ||
except FileNotFoundError: | ||
interwiki_map = {} | ||
# we must add entries for 'Self' and our interwikiname, | ||
# if you are not running the built-in desktop server change these to your wiki URL | ||
interwiki_map[interwikiname] = 'http://127.0.0.1:8080/' | ||
interwiki_map['Self'] = 'http://127.0.0.1:8080/' | ||
interwiki_map[interwikiname] = "http://127.0.0.1:8080/" | ||
interwiki_map["Self"] = "http://127.0.0.1:8080/" | ||
|
||
# sitename is displayed in heading of all wiki pages | ||
sitename = 'My MoinMoin' | ||
sitename = "My MoinMoin" | ||
|
||
# see https://www.moinmo.in/ThemeMarket for contributed moin2 themes | ||
# default theme is topside | ||
# theme_default = "modernized" # or basic or topside_cms | ||
|
||
# prevent multiple users from editing an item at same time | ||
edit_locking_policy = 'lock' | ||
edit_locking_policy = "lock" | ||
edit_lock_time = 20 # minutes, resets when the Preview button is clicked | ||
|
||
# number of quicklinks to show in navigation bar, mouseover shows all | ||
|
@@ -121,22 +126,24 @@ class Config(DefaultConfig): | |
# New user registration option; if set to True use the command line to create the first superuser: | ||
# moin account-create --name MyName --email [email protected] --password ******** | ||
registration_only_by_superuser = True # True disables self-registration, recommended for public wikis | ||
registration_hint = 'To contribute to this wiki as an editor send an email with your preferred UserName to [email protected].' | ||
registration_hint = ( | ||
"To contribute to this wiki as an editor send an email with your preferred UserName to [email protected]." | ||
) | ||
|
||
# if registration_only_by_superuser=False then making this True verifies a working email address | ||
# for users who self-register | ||
user_email_verification = False | ||
|
||
# Define the super user who will have access to administrative functions like user registration, | ||
# password reset, disabling users, etc. | ||
acl_functions = 'YOUR-SUPER-USER-NAME:superuser' | ||
acl_functions = "YOUR-SUPER-USER-NAME:superuser" | ||
# OR, if you have a large active wiki with many administrators and editors you may want to | ||
# create a ConfigGroup or a WikiGroup. Group names may be used in place of user names | ||
# above and in ACL rules defined below. Read about it here: | ||
# https://moin-20.readthedocs.io/en/latest/admin/configure.html#group-backend-configuration | ||
|
||
# File Storage backends are recommended for most wikis | ||
uri = f'stores:fs:{data_dir}/%(backend)s/%(kind)s' # use file system for storage | ||
uri = f"stores:fs:{data_dir}/%(backend)s/%(kind)s" # use file system for storage | ||
# uri = 'stores:sqlite:{0}/mywiki_%(backend)s_%(kind)s.db'.format(data_dir) # sqlite, 1 table per db | ||
# uri = 'stores:sqlite:{0}/mywiki_%(backend)s.db::%(kind)s'.format(data_dir) # sqlite, 2 tables per db | ||
# sqlite via SQLAlchemy | ||
|
@@ -146,12 +153,12 @@ class Config(DefaultConfig): | |
namespaces = { | ||
# maps namespace name -> backend name | ||
# these 3 standard namespaces are required, these have separate backends | ||
NAMESPACE_DEFAULT: 'default', | ||
NAMESPACE_USERS: 'users', | ||
NAMESPACE_USERPROFILES: 'userprofiles', | ||
NAMESPACE_DEFAULT: "default", | ||
NAMESPACE_USERS: "users", | ||
NAMESPACE_USERPROFILES: "userprofiles", | ||
# namespaces for editor help files are optional, if unwanted delete here and in backends and acls | ||
NAMESPACE_HELP_COMMON: 'help-common', # contains media files used by other language helps | ||
NAMESPACE_HELP_EN: 'help-en', # replace this with help-de, help-ru, help-pt_BR etc. | ||
NAMESPACE_HELP_COMMON: "help-common", # contains media files used by other language helps | ||
NAMESPACE_HELP_EN: "help-en", # replace this with help-de, help-ru, help-pt_BR etc. | ||
# define custom namespaces using the default backend | ||
# 'foo': 'default', | ||
# custom namespace with a separate backend (a wiki/data/bar directory will be created) | ||
|
@@ -162,12 +169,12 @@ class Config(DefaultConfig): | |
# the feature to use different storage types for each namespace is not implemented so use None below. | ||
# the storage type for all backends is set in 'uri' above, | ||
# all values in `namespace` dict must be defined as keys in `backends` dict | ||
'default': None, | ||
'users': None, | ||
'userprofiles': None, | ||
"default": None, | ||
"users": None, | ||
"userprofiles": None, | ||
# help namespaces are optional | ||
'help-common': None, | ||
'help-en': None, | ||
"help-common": None, | ||
"help-en": None, | ||
# required for foo and bar namespaces as defined above | ||
# 'foo': None, | ||
# 'bar': None, | ||
|
@@ -182,40 +189,40 @@ class Config(DefaultConfig): | |
# | ||
# most wiki data will be stored in NAMESPACE_DEFAULT | ||
NAMESPACE_DEFAULT: dict( | ||
before='YOUR-SUPER-EDITOR:read,write,create,destroy,admin', | ||
default='YOUR-TRUSTED-EDITORS-GROUP:read,write,create All:read', | ||
after='', | ||
hierarchic=False, ), | ||
before="YOUR-SUPER-EDITOR:read,write,create,destroy,admin", | ||
default="YOUR-TRUSTED-EDITORS-GROUP:read,write,create All:read", | ||
after="", | ||
hierarchic=False, | ||
), | ||
# user home pages should be stored here | ||
NAMESPACE_USERS: dict( | ||
before='YOUR-SUPER-EDITOR:read,write,create,destroy,admin', | ||
default='YOUR-TRUSTED-EDITORS-GROUP:read,write,create All:read', | ||
after='', | ||
before="YOUR-SUPER-EDITOR:read,write,create,destroy,admin", | ||
default="YOUR-TRUSTED-EDITORS-GROUP:read,write,create All:read", | ||
after="", | ||
# True enables possibility of an admin creating ACL rules for a user's subpages | ||
hierarchic=True, ), | ||
hierarchic=True, | ||
), | ||
# contains user data that must be kept secret, dis-allow access for all | ||
NAMESPACE_USERPROFILES: dict( | ||
before='All:', | ||
default='', | ||
after='', | ||
hierarchic=False, ), | ||
NAMESPACE_USERPROFILES: dict(before="All:", default="", after="", hierarchic=False), | ||
# editor help namespacess are optional | ||
'help-common': dict( | ||
before='YOUR-SUPER-EDITOR:read,write,create,destroy,admin', | ||
default='YOUR-TRUSTED-EDITORS-GROUP:read,write,create All:read', | ||
after='', | ||
hierarchic=False, ), | ||
'help-en': dict( | ||
before='YOUR-SUPER-EDITOR:read,write,create,destroy,admin', | ||
default='YOUR-TRUSTED-EDITORS-GROUP:read,write,create All:read', | ||
after='', | ||
hierarchic=False, ), | ||
"help-common": dict( | ||
before="YOUR-SUPER-EDITOR:read,write,create,destroy,admin", | ||
default="YOUR-TRUSTED-EDITORS-GROUP:read,write,create All:read", | ||
after="", | ||
hierarchic=False, | ||
), | ||
"help-en": dict( | ||
before="YOUR-SUPER-EDITOR:read,write,create,destroy,admin", | ||
default="YOUR-TRUSTED-EDITORS-GROUP:read,write,create All:read", | ||
after="", | ||
hierarchic=False, | ||
), | ||
} | ||
namespace_mapping, backend_mapping, acl_mapping = create_mapping(uri, namespaces, backends, acls, ) | ||
namespace_mapping, backend_mapping, acl_mapping = create_mapping(uri, namespaces, backends, acls) | ||
# define mapping of namespaces to unique item_roots (home pages within namespaces). | ||
root_mapping = {'users': 'UserHome', } | ||
root_mapping = {"users": "UserHome"} | ||
# default root, use this value by default for all namespaces | ||
default_root = 'Home' | ||
default_root = "Home" | ||
|
||
# Enable only selected content types for new items. Default: [] (all types enabled). | ||
# contenttype_enabled = ['MoinMoin', 'PDF', 'PNG', 'JPEG'] | ||
|
@@ -225,35 +232,36 @@ class Config(DefaultConfig): | |
# add or remove packages - see https://github.com/xstatic-py/xstatic for info about xstatic | ||
# it is uncommon to change these because of local customizations | ||
from xstatic.main import XStatic | ||
|
||
# names below must be package names | ||
mod_names = [ | ||
'jquery', | ||
'jquery_file_upload', | ||
'bootstrap', | ||
'font_awesome', | ||
'ckeditor', | ||
'autosize', | ||
'svgedit_moin', | ||
'jquery_tablesorter', | ||
'pygments', | ||
"jquery", | ||
"jquery_file_upload", | ||
"bootstrap", | ||
"font_awesome", | ||
"ckeditor", | ||
"autosize", | ||
"svgedit_moin", | ||
"jquery_tablesorter", | ||
"pygments", | ||
] | ||
pkg = __import__('xstatic.pkg', fromlist=mod_names) | ||
pkg = __import__("xstatic.pkg", fromlist=mod_names) | ||
for mod_name in mod_names: | ||
mod = getattr(pkg, mod_name) | ||
xs = XStatic(mod, root_url='/static', provider='local', protocol='http') | ||
xs = XStatic(mod, root_url="/static", provider="local", protocol="http") | ||
serve_files[xs.name] = xs.base_dir | ||
|
||
|
||
# flask settings require all caps | ||
MOINCFG = Config # adding MOINCFG=<path> to OS environment overrides CWD | ||
# Flask settings - see the flask documentation about their meaning | ||
SECRET_KEY = 'WARNING: set this to a unique string to create secure cookies' | ||
SECRET_KEY = "WARNING: set this to a unique string to create secure cookies" | ||
DEBUG = False # use True for development only, not for public sites! | ||
TESTING = False # built-in server (./m run) ignores TESTING and DEBUG settings | ||
# per https://flask.palletsprojects.com/en/1.1.x/security/#set-cookie-options | ||
SESSION_COOKIE_SECURE = False # flask default is False | ||
SESSION_COOKIE_HTTPONLY = True # flask default is True | ||
SESSION_COOKIE_SAMESITE = 'Lax' # flask default is None | ||
SESSION_COOKIE_SAMESITE = "Lax" # flask default is None | ||
# SESSION_COOKIE_NAME = 'session' | ||
# PERMANENT_SESSION_LIFETIME = timedelta(days=31) | ||
# USE_X_SENDFILE = False | ||
|