More cleanup and extension of config-variable processing.
authorEric S. Raymond <esr@thyrsus.com>
Sun, 30 Sep 2012 15:07:41 +0000 (11:07 -0400)
committerEric S. Raymond <esr@thyrsus.com>
Sun, 30 Sep 2012 15:07:41 +0000 (11:07 -0400)
irkerhook.py
irkerhook.xml

index 29e035599cc2a6281ba3edd8e7fa75b6ec67d89c..6a10862348d87691b369a639139be7e5b9d700ca 100755 (executable)
 #
 # See the irkerhook manual page in the distribution for a detailed
 # explanation of how to configure this hook.
-#
-# Other configuration changes you may want to make are to:
-#
-# urlprefix: the current version should work for viewcvs or gitweb
-# installations, but will require modification for other systems.
-#
-# tinyfier: If your project maintains its own url-shrinking service
 
 # The default location of the irker proxy, if the project configuration
 # does not override it.
 default_server = "localhost"
 IRKER_PORT = 6659
 
-# The default service used to turn your gitwebbish URL into a tinyurl so it
+# The default service used to turn your web-view URL into a tinyurl so it
 # will take up less space on the IRC notification line.
-tinyifier = "http://tinyurl.com/api-create.php?url="
+default_tinyifier = "http://tinyurl.com/api-create.php?url="
 
 # Map magic urlprefix values to actual URL prefixes.
 urlprefixmap = {
@@ -37,6 +30,9 @@ urlprefixmap = {
     "cgit": "http://%(host)s/cgi-bin/cgit.cgi/%(repo)s/commit/?id=",
     }
 
+# By default, the channel list includes the freenode #commits list 
+default_channels = "irc://chat.freenode.net/%(project)s,irc://chat.freenode.net/#commits"
+
 #
 # No user-serviceable parts below this line:
 #
@@ -56,7 +52,7 @@ def urlify(extractor, commit):
     prefix = extractor.urlprefix % extractor.__dict__
     # Try to tinyfy a reference to a web view for this commit.
     try:
-        url = open(urllib.urlretrieve(tinyifier + prefix + commit)[0]).read()
+        url = open(urllib.urlretrieve(extractor.tinyifier + prefix + commit)[0]).read()
     except:
         url = prefix + commit
     return url
@@ -72,6 +68,7 @@ class GitExtractor:
         self.tcp = do("git config --bool --get irker.tcp")
         self.template = '%(project)s: %(author)s %(repo)s:%(branch)s * %(rev)s / %(files)s: %(logmsg)s %(url)s'
         self.urlprefix = do("git config --get irker.urlprefix") or "gitweb"
+        self.tinyifier = default_tinyifier
         # This one is git-specific
         self.revformat = do("git config --get irker.revformat")
         # The project variable defaults to the name of the repository toplevel.
@@ -164,6 +161,7 @@ class SvnExtractor:
         self.rev = "r%s" % self.commit
         self.template = '%(project)s: %(author)s %(repo)s * %(rev)s / %(files)s: %(logmsg)s %(url)s'
         self.urlprefix = "viewcvs"
+        self.tinyifier = default_tinyifier
         load_preferences(self, os.path.join(self.repository, "irker.conf"))
     def svnlook(self, info):
         return do("svnlook %s %s --revision %s" % (shellquote(info), shellquote(self.repository), shellquote(self.commit)))
@@ -188,11 +186,9 @@ if __name__ == "__main__":
             print "irkerhook.py: version", version
             sys.exit(0)
 
-    # Gather info for repo type discrimination, make globals settable
+    # Gather info for repo type discrimination
     for tok in arguments:
-        if tok.startswith("tinyfier="):
-            tinyfier = tok[9:]
-        elif tok.startswith("repository="):
+        if tok.startswith("repository="):
             repository = tok[11:]
 
     # Determine the repository type. Default to git unless user has pointed
@@ -223,9 +219,8 @@ if __name__ == "__main__":
                 else:
                     setattr(extractor, key, val)
 
-    # By default, the channel list includes the freenode #commits list 
     if not extractor.channels:
-        extractor.channels = "irc://chat.freenode.net/%s,irc://chat.freenode.net/#commits" % extractor.project
+        extractor.channels = default_channels % extractor.__dict__
     # Other defaults get set here
     if not extractor.repo:
         extractor.repo = extractor.project.lower()
index 759e537518790190a4af89b5d34660cf9cad5278..9efd9ee914f978757836b88f68274e59cb339d7a 100644 (file)
@@ -69,7 +69,7 @@ specified, defaults to a lowercased copy of the project name.</para>
 <term>channels</term>
 <listitem>
 <para>An IRC channel URL, or comma-separated list of same, identifying
-channels to which notofications are to be sent. If not specified, the
+channels to which notifications are to be sent. If not specified, the
 defaults channel list id the freenode #commits channel plus the freenode
 channel named by the project variable.</para>
 </listitem>
@@ -100,6 +100,18 @@ work if you have a typical gitweb/cgit setup.</para>
 field in commit notifications will be suppressed. Other magic values
 are "cgit", "gitweb", and "viewcvs", which expand to URL templates
 that will usually work with those systems.</para>
+
+<para>The magic cookies "%(host)s" and %(repo)s" may occur in this
+URL.  The former is expanded to the FQDN of the host on which
+<application>irkerhook.py</application> is running; the latter is
+expanded to the value of the "repo" variable.</para>
+</listitem>
+</varlistentry>
+<varlistentry>
+<term>tinyifier</term>
+<listitem>
+<para>URL template pointing to a service for compressing URLs so they 
+will take up less space in the notification line.</para>
 </listitem>
 </varlistentry>
 </variablelist>