Akash Sinha avatar Akash Sinha committed 77f05fb

few more files merged with main

Comments (0)

Files changed (5)

MoinMoin/config/default.py

         if self.secrets is None:  # admin did not setup a real secret
             raise error.ConfigurationError("No secret configured! You need to set secrets = 'somelongsecretstring' in your wiki config.")
 
-        if self.interwikiname is None:  # admin did not setup a real interwikiname
-            raise error.ConfigurationError("No interwikiname configured! You need to set interwikiname = u'YourUniqueStableInterwikiName' in your wiki config.")
-
         secret_key_names = ['security/ticket', ]
         if self.textchas:
             secret_key_names.append('security/textcha')
   (
     ('sitename', u'Untitled Wiki',
      "Short description of your wiki site, displayed below the logo on each page, and used in RSS documents as the channel title [Unicode]"),
-    ('interwikiname', None, "unique, stable and required InterWiki name (prefix, moniker) of the site [Unicode]"),
+    ('interwikiname', None, "unique and stable InterWiki name (prefix, moniker) of the site [Unicode], or None"),
     ('html_pagetitle', None, "Allows you to set a specific HTML page title (if None, it defaults to the value of `sitename`) [Unicode]"),
     ('navi_bar', [
         ('wikilink', 'frontend.show_root', dict(), L_('Home'), L_('Home Page')),

MoinMoin/script/maint/index.py

 
         backend = flaskg.unprotected_storage = app.unprotected_storage
         index_object = WhooshIndex(index_dir=app.cfg.index_dir_tmp)
-        interwikiname = app.cfg.interwikiname
+        interwikiname = app.cfg.interwikiname or u''
         if os.path.samefile(app.cfg.index_dir_tmp, app.cfg.index_dir):
             raise FatalError(u"cfg.index_dir and cfg.index_dir_tmp must point to different directories.")
 

MoinMoin/storage/backends/indexing.py

     Index for Items/Revisions
     """
     def __init__(self, cfg):
-        self.wikiname = cfg.interwikiname
+        self.wikiname = cfg.interwikiname or u''
         self.index_object = WhooshIndex(cfg=cfg)
 
     def close(self):
 
 from MoinMoin import config, wikiutil
 from MoinMoin.i18n import _, L_, N_
-from MoinMoin.util.interwiki import getInterwikiHome, getInterwikiName, is_local_wiki
+from MoinMoin.util.interwiki import getInterwikiHome, is_local_wiki
 from MoinMoin.util.crypto import crypt_password, upgrade_password, valid_password, \
                                  generate_token, valid_token
 
         :param tm: timestamp
         """
         if self.valid:
-            self.bookmarks[self._cfg.interwikiname] = int(tm)
+            interwikiname = self._cfg.interwikiname or u''
+            self.bookmarks[interwikiname] = int(tm)
             self.save()
 
     def getBookmark(self):
         :returns: bookmark timestamp or None
         """
         bm = None
+        interwikiname = self._cfg.interwikiname or u''
         if self.valid:
             try:
-                bm = self.bookmarks[self._cfg.interwikiname]
+                bm = self.bookmarks[interwikiname]
             except (ValueError, KeyError):
                 pass
         return bm
         :rtype: int
         :returns: 0 on success, 1 on failure
         """
+        interwikiname = self._cfg.interwikiname or u''
         if self.valid:
             try:
-                del self.bookmarks[self._cfg.interwikiname]
+                del self.bookmarks[interwikiname]
             except KeyError:
                 return 1
             self.save()
 
         import re
         # Create a new list with both names and interwiki names.
-        pages = pagelist[:] # TODO: get rid of non-interwiki subscriptions?
-        pages += [getInterwikiName(pagename) for pagename in pagelist]
+        pages = pagelist[:]
+        if self._cfg.interwikiname:
+            pages += [self._interWikiName(pagename) for pagename in pagelist]
         # Create text for regular expression search
         text = '\n'.join(pages)
 
         :rtype: bool
         :returns: if page was subscribed
         """
-        pagename = getInterwikiName(pagename)
+        if self._cfg.interwikiname:
+            pagename = self._interWikiName(pagename)
+
         if pagename not in self.subscribed_items:
             self.subscribed_items.append(pagename)
             self.save()
+
             # XXX SubscribedToPageEvent
             return True
+
         return False
 
     def unsubscribe(self, pagename):
             self.subscribed_items.remove(pagename)
             changed = True
 
-        interWikiName = getInterwikiName(pagename)
+        interWikiName = self._interWikiName(pagename)
         if interWikiName and interWikiName in self.subscribed_items:
             self.subscribed_items.remove(interWikiName)
             changed = True
         for pagename in pagelist:
             if pagename in self.quicklinks:
                 return True
-            interWikiName = getInterwikiName(pagename)
+            interWikiName = self._interWikiName(pagename)
             if interWikiName and interWikiName in self.quicklinks:
                 return True
 
         :returns: if pagename was added
         """
         changed = False
-        interWikiName = getInterwikiName(pagename)
+        interWikiName = self._interWikiName(pagename)
         if interWikiName:
             if pagename in self.quicklinks:
                 self.quicklinks.remove(pagename)
         :returns: if pagename was removed
         """
         changed = False
-        interWikiName = getInterwikiName(pagename)
+        interWikiName = self._interWikiName(pagename)
         if interWikiName and interWikiName in self.quicklinks:
             self.quicklinks.remove(interWikiName)
             changed = True
             self.save()
         return changed
 
+    def _interWikiName(self, pagename):
+        """ Return the inter wiki name of a page name
+
+        :param pagename: page name
+        :type pagename: unicode
+        """
+        if not self._cfg.interwikiname:
+            return None
+
+        return "%s:%s" % (self._cfg.interwikiname, pagename)
+
     # -----------------------------------------------------------------
     # Trail
 
 
         :param item_name: the item name (unicode) to add to the trail
         """
-        item_name = getInterwikiName(item_name)
+        # Save interwiki links internally
+        if self._cfg.interwikiname:
+            item_name = self._interWikiName(item_name)
         trail_in_session = session.get('trail', [])
         trail = trail_in_session[:]
         trail = [i for i in trail if i != item_name] # avoid dupes
                     sitename=self._cfg.sitename or "Wiki")
         mailok, msg = sendmail.sendmail([self.email], subject, text, mail_from=self._cfg.mail_from)
         return mailok, msg
+

MoinMoin/util/interwiki.py

         return wikiurl + wikitail
 
 
-def getInterwikiName(item_name):
-    """
-    Get the (fully qualified) interwiki name of a local item name.
-
-    :param item_ame: item name (unicode)
-    :rtype: unicode
-    :returns: wiki_name:item_name
-    """
-    return "%s:%s" % (app.cfg.interwikiname, item_name)
-
-
 def getInterwikiHome(username):
     """
     Get a user's homepage.
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.