def test_load_file(self): """ Test that InterWikiMap.from_file correctly loads file objects. """ tmpdir = tempfile.mkdtemp() # test an invalid file with pytest.raises(IOError): InterWikiMap.from_file(os.path.join(tmpdir, 'void')) # test a consistent valid file testfile = os.path.join(tmpdir, 'foo.iwm') with open(testfile, 'w') as f: f.write('foo bar\n' 'baz spam\n' 'ham end end # this is really the end.') testiwm = InterWikiMap.from_file(testfile) assert testiwm.iwmap == dict(foo='bar', baz='spam', ham='end end') # test a malformed file testfile = os.path.join(tmpdir, 'bar.iwm') with open(testfile, 'w') as f: f.write('# This is a malformed interwiki file\n' 'fails # ever') with pytest.raises(ValueError): InterWikiMap.from_file(testfile) # finally destroy everything shutil.rmtree(tmpdir)
def test_real_interwiki_map(self): """ Test a 'real' interwiki file. """ abspath = __file__.rsplit('MoinMoin')[0] testfile = os.path.join(abspath, 'contrib', 'interwiki', 'intermap.txt') testiwm = InterWikiMap.from_file(testfile) assert 'MoinMaster' in testiwm.iwmap assert testiwm.iwmap['MoinMaster'] == 'http://master.moinmo.in/' assert 'PythonInfo' in testiwm.iwmap assert 'this' not in testiwm.iwmap assert testiwm.iwmap['MoinMoin'] == 'http://moinmo.in/'
def test_load_string(self): """ Test that InterWikiMap.from_unicode correctly loads unicode objects. """ # test for void wiki maps assert InterWikiMap.from_string(u'').iwmap == dict() assert InterWikiMap.from_string(u'#spam\r\n').iwmap == dict() # test for comments s = ('# foo bar\n' '#spamham\r\n' '# space space\n' 'foo bar\r\n' 'ham spam # this is a valid description') assert InterWikiMap.from_string(s).iwmap == dict(foo='bar', ham='spam') # test for valid strings s = ('link1 http://link1.com/\r\n' 'link2 http://link2.in/\r\n') assert (InterWikiMap.from_string(s).iwmap == dict( link1='http://link1.com/', link2='http://link2.in/')) # test invalid strings with pytest.raises(ValueError): InterWikiMap.from_string(u'foobarbaz')
def test_load_string(self): """ Test that InterWikiMap.from_unicode correctly loads unicode objects. """ # test for void wiki maps assert InterWikiMap.from_string(u'').iwmap == dict() assert InterWikiMap.from_string(u'#spam\r\n').iwmap == dict() # test for comments s = ('# foo bar\n' '#spamham\r\n' '# space space\n' 'foo bar\r\n' 'ham spam # this is a valid description') assert InterWikiMap.from_string(s).iwmap == dict(foo='bar', ham='spam') # test for valid strings s = ('link1 http://link1.com/\r\n' 'link2 http://link2.in/\r\n') assert (InterWikiMap.from_string(s).iwmap == dict(link1='http://link1.com/', link2='http://link2.in/')) # test invalid strings with pytest.raises(ValueError): InterWikiMap.from_string(u'foobarbaz')
class Config(DefaultConfig): # We assume this structure for a mercurial clone or simple "unpack and run" scenario: # moin-2.0/ # wikiconfig_dir points here: clone root or unpack directory, contains this file. # wikiconfig.py # the file you are reading now. # wiki/ # instance_dir variable points here: created by running "./m sample" or "./m new-wiki" commands. # data/ # data_dir variable points here. # index/ # index_storage variable points here. # contrib/ # interwiki/ # intermap.txt # interwiki_map variable points here. # docs/ # _build/ # html/ # serve_files['docs']: html docs made by sphinx, create by running "./m docs" command. # wiki_local/ # serve_files['wiki_local']: store custom logos, CSS, templates, etc. here # If that's not true, adjust these paths 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"), ), {} # setup static files' serving: serve_files = dict( docs=os.path.join(wikiconfig_dir, 'docs', '_build', 'html'), # html docs made by sphinx wiki_local=os.path.join( wikiconfig_dir, 'wiki_local'), # store custom logos, CSS, templates, etc. here ) # copy templates/snippets.html to directory below and edit per requirements to customize logos, etc. template_dirs = [ os.path.join(wikiconfig_dir, 'wiki_local'), ] # it is required that you set this to a unique, stable and non-empty name: interwikiname = u'MyMoinMoin' # load the interwiki map from intermap.txt: interwiki_map = InterWikiMap.from_file( os.path.join(wikiconfig_dir, 'contrib', 'interwiki', 'intermap.txt')).iwmap # we must add entries for 'Self' and our interwikiname, change these if you are not running the built-in desktop server: 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 = u'My MoinMoin' # default theme is topside # theme_default = u"modernized" # or basic or topside_cms # read about PRIVACY ISSUES in docs before uncommenting the line below to use gravatars # user_use_gravatar = True # read about SECURITY ISSUES in docs before uncommenting the line below allowing users # to edit style attributes in HTML and Markdown items # allow_style_attributes = True # default passwords are required to be => 8 characters with minimum of 5 unique characters # password_checker = None # no password length or quality checking # password_checker = lambda cfg, name, pw: _default_password_checker(cfg, name, pw, min_length=8, min_different=5) # default # optional, configure email, uncomment line below and choose (a) or (b) # mail_from = u"wiki <*****@*****.**>" # the "from:" address [Unicode] # (a) using an SMTP server, e.g. "mail.provider.com" with optional `:port`appendix, which defaults to 25 (set None to disable mail) # mail_smarthost = "smtp.example.org" # mail_username = "******" # if you need to use SMTP AUTH at your mail_smarthost: # mail_password = "******" # (b) an alternative to SMTP is the sendmail commandline tool: # mail_sendmail = "/usr/sbin/sendmail -t -i" # list of admin emails admin_emails = [] # send tracebacks to admins email_tracebacks = False # add or remove packages - see https://bitbucket.org/thomaswaldmann/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', 'twikidraw_moin', 'anywikidraw', 'jquery_tablesorter', 'pygments', ] 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') serve_files[xs.name] = xs.base_dir # create a super user who will have access to administrative functions # acl_functions = u'+YourName:superuser' # OR, create several WikiGroups and create several superusers and turn off textchas for selected users # SuperGroup and TrustedEditorGroup reference WikiGroups you must create # acl_functions = u'+YourName:superuser SuperGroup:superuser YourName:notextcha TrustedEditorGroup:notextcha' # This provides a simple default setup for your backend configuration. # 'stores:fs:...' indicates that you want to use the filesystem backend. # Alternatively you can set up the mapping yourself (see HelpOnStorageConfiguration). namespace_mapping, backend_mapping, acl_mapping = create_simple_mapping( uri='stores:fs:{0}/%(backend)s/%(kind)s'.format(data_dir), # XXX we use rather relaxed ACLs for the development wiki: default_acl=dict( before=u'', default=u'All:read,write,create,destroy,admin', after=u'', hierarchic=False, ), users_acl=dict( before=u'', default=u'All:read,write,create,destroy,admin', after=u'', hierarchic=False, ), # userprofiles contain only metadata, no content will be created userprofiles_acl=dict( before=u'All:', default=u'', after=u'', hierarchic=False, ), ) # uncomment and improve block below to enable textchas """
class Config(DefaultConfig): # Directory containing THIS wikiconfig: wikiconfig_dir = os.path.abspath(os.path.dirname(__file__)) # We assume this structure for a simple "unpack and run" scenario: # wikiconfig.py # wiki/ # data/ # index/ # contrib/ # interwiki/ # intermap.txt # If that's not true, feel free to adjust the pathes. instance_dir = os.path.join(wikiconfig_dir, 'wiki') data_dir = os.path.join( instance_dir, 'data') # Note: this used to have a trailing / in the past index_storage = 'FileStorage', (os.path.join(instance_dir, "index"), ), {} # This provides a simple default setup for your backend configuration. # 'stores:fs:...' indicates that you want to use the filesystem backend. # Alternatively you can set up the mapping yourself (see HelpOnStorageConfiguration). namespace_mapping, backend_mapping, acl_mapping = create_simple_mapping( uri='stores:fs:{0}/%(backend)s/%(kind)s'.format(data_dir), # XXX we use rather relaxed ACLs for the development wiki: default_acl=dict( before=u'', default=u'All:read,write,create,destroy,admin', after=u'', hierarchic=False, ), userprofiles_acl=dict( before=u'', default=u'All:read,write,create,destroy,admin', after=u'', hierarchic=False, ), ) # for display purposes: sitename = u'My MoinMoin' # it is required that you set this to a unique, stable and non-empty name: interwikiname = u'MyMoinMoin' # Load the interwiki map from intermap.txt: interwiki_map = InterWikiMap.from_file( os.path.join(wikiconfig_dir, 'contrib', 'interwiki', 'intermap.txt')).iwmap # we must add entries for 'Self' and our interwikiname: interwiki_map[interwikiname] = 'http://127.0.0.1:8080/' interwiki_map['Self'] = 'http://127.0.0.1:8080/' # setup static files' serving: serve_files = dict( docs=os.path.join(wikiconfig_dir, 'docs', '_build', 'html'), # html docs made by sphinx ) # see https://bitbucket.org/thomaswaldmann/xstatic for infos about xstatic: from xstatic.main import XStatic # names below must be package names mod_names = [ 'jquery', 'jquery_file_upload', 'bootstrap', 'font_awesome', 'ckeditor', 'autosize', 'svgedit_moin', 'twikidraw_moin', 'anywikidraw', 'jquery_tablesorter', 'pygments', ] 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') serve_files[xs.name] = xs.base_dir # list of admin emails admin_emails = [] # send tracebacks to admins email_tracebacks = False
class Config(DefaultConfig): # vvv DON'T TOUCH THIS EXCEPT IF YOU KNOW WHAT YOU DO vvv # Directory containing THIS wikiconfig: wikiconfig_dir = os.path.abspath(os.path.dirname(__file__)) # We assume this structure for a simple "unpack and run" scenario: # wikiconfig.py # wiki/ # data/ # contrib/ # xml/ # preloaded_items.xml # If that's not true, feel free to adjust the pathes. instance_dir = os.path.join(wikiconfig_dir, 'wiki') data_dir = os.path.join( instance_dir, 'data') # Note: this used to have a trailing / in the past # This puts the contents from the specified xml file (a serialized backend) into your # backend(s). You can remove this after the first request to your wiki or # from the beginning if you don't want to use this feature at all. load_xml = os.path.join(wikiconfig_dir, 'contrib', 'xml', 'preloaded_items.xml') #save_xml = os.path.join(wikiconfig_dir, 'contrib', 'xml', 'saved_items.xml') # This provides a simple default setup for your backend configuration. # 'fs:' indicates that you want to use the filesystem backend. You can also use # 'hg:' instead to indicate that you want to use the mercurial backend. # Alternatively you can set up the mapping yourself (see HelpOnStorageConfiguration). namespace_mapping, router_index_uri = create_simple_mapping( backend_uri='fs2:%s/%%(nsname)s' % data_dir, # XXX we use rather relaxed ACLs for the development wiki: content_acl=dict( before=u'', default=u'All:read,write,create,destroy,admin', after=u'', ), user_profile_acl=dict( before=u'', default=u'All:read,write,create,destroy,admin', after=u'', ), ) # Load the interwiki map from intermap.txt: interwiki_map = InterWikiMap.from_file( os.path.join(wikiconfig_dir, 'contrib', 'interwiki', 'intermap.txt')).iwmap sitename = u'My MoinMoin' # for now we load some 3rd party stuff from the place within moin where it is currently located, # but soon we'll get rid of this stuff: serve_files = dict( # see "quickinstall" script about how to get those files there ckeditor=os.path.join(wikiconfig_dir, 'env', 'ckeditor'), jquery=os.path.join(wikiconfig_dir, 'env', 'jquery'), svgweb=os.path.join(wikiconfig_dir, 'env', 'svgweb', 'src'), anywikidraw=os.path.join(wikiconfig_dir, 'env', 'AnyWikiDraw', 'anywikidraw', 'moinmoin'), twikidraw=os.path.join(wikiconfig_dir, 'env', 'TWikiDrawPlugin'), svgedit=os.path.join(wikiconfig_dir, 'env', 'svg-edit'), )