Author: saces
Date: 2008-11-09 16:49:45 +0000 (Sun, 09 Nov 2008)
New Revision: 23444
Modified:
trunk/apps/pyFreenetHg/FreenetHg.py
trunk/apps/pyFreenetHg/ReadMe.html
Log:
sync with 67:fdf255c70de5 (USK at
fQGiK~CfI8zO4cuNyhPRLqYZ5TyGUme8lMiRnS9TCaU,E3S1MLoeeeEM45fDLdVV~n8PCr9pt6GMq0tuH4dRP7c,AQACAAE/freenethg/23)
Modified: trunk/apps/pyFreenetHg/FreenetHg.py
===================================================================
--- trunk/apps/pyFreenetHg/FreenetHg.py 2008-11-09 14:20:49 UTC (rev 23443)
+++ trunk/apps/pyFreenetHg/FreenetHg.py 2008-11-09 16:49:45 UTC (rev 23444)
@@ -24,17 +24,56 @@
class IndexPageMaker(object):
"""class for generate an index page"""
-
- def getBuildInIndexPage(self):
- return '<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">\n \
+
+ def get_default_index_page(self, data):
+ """generates the built-in version of index.html for repository"""
+
+ template = Template('<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01
Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">\n \
<html>\n<head>\n<meta http-equiv="Content-Type"
content="text/html; charset=UTF-8">\n \
<title>Sorry, Not a Freesite</title>\n</head>\n<body>\n \
Sorry, this is not a freesite, this is a mercurial
repository.<br>\n \
- Please use hg clone|pull http-static://127.0.0.1:8888/URI to
use the repository.<br>\n \
+ Please use hg clone|pull static-http://127.0.0.1:8888/URI to
use the repository.<br>\n \
<p> </p>\n \
created with <a href="/USK at
MYLAnId-ZEyXhDGGbYOa1gOtkZZrFNTXjFl1dibLj9E,Xpu27DoAKKc8b0718E-ZteFrGqCYROe7XBBJI57pB4M,AQACAAE/pyFreenetHg/1/">pyFreenetHg</a>\n
\
- </body>\n</html>\n'
+ </body>\n</html>\n')
+ return template.substitute(data)
+
+ def get_custom_index_page(self, ui):
+ """generates the custom version of index.html for repository"""
+
+ f = open(ui.config('freenethg', 'indextemplate'), 'r')
+ template = Template(f.read())
+ f.close()
+
+ template_data = {'uri' : ui.config('freenethg', 'requesturi') or 'URI',
+ 'fmsuser' : ui.config('freenethg', 'fmsuser') or '',
+ }
+
+ page = template.substitute(template_data)
+ return page
+
+ def get_index_page(self, ui):
+ """returns index.html page for repository insert.
+ either the built-in version or from a user template"""
+
+ # this dict holds the key-value-pairs for default template
+ # empty at the moment
+ default_data = {}
+
+ if ui.config('freenethg', 'indextemplate'):
+ try:
+ page = self.get_custom_index_page(ui)
+ except Exception, e:
+ print "Error while processing template from %s:" %
ui.config('freenethg', 'indextemplate')
+ print e
+ print "Using default template"
+ page = self.get_default_index_page(default_data)
+ else:
+ page = self.get_default_index_page(default_data)
+
+ return page
+
class FMS_NNTP(NNTP):
"""class for posts to newsgroups on nntp servers"""
@@ -285,7 +324,7 @@
if not opts.get('fcpport'):
opts['fcpport'] = ui.config('freenethg', 'fcpport')
cmd = "ClientPutComplexDir\n" + "URI=" + uri + "\nIdentifier=" + id
- cmd = cmd + "\nVerbosity=-1\nPriorityClass=1\n"
+ cmd = cmd +
"\nVerbosity=-1\nPriorityClass=1\nMaxRetries=5\nDontCompress=true\n"
composer = _static_composer(repo)
@@ -340,15 +379,13 @@
#fcpopts['logfunc'] = ui.log
node = myFCP(**fcpopts)
-
-
- indexpage = IndexPageMaker().getBuildInIndexPage()
-
cmd = "ClientPutComplexDir\n" + "URI=" + uri + "\nIdentifier=" + id
- cmd = cmd + "\nVerbosity=-1\nPriorityClass=1\n"
+ cmd = cmd +
"\nVerbosity=-1\nPriorityClass=1\nMaxRetries=5\nDontCompress=true\n"
composer = _static_composer(repo)
+ page_maker = IndexPageMaker()
+ indexpage = page_maker.get_index_page(ui)
composer.addIndex(indexpage)
print "Debug: " + cmd + composer.getCmd()
Modified: trunk/apps/pyFreenetHg/ReadMe.html
===================================================================
--- trunk/apps/pyFreenetHg/ReadMe.html 2008-11-09 14:20:49 UTC (rev 23443)
+++ trunk/apps/pyFreenetHg/ReadMe.html 2008-11-09 16:49:45 UTC (rev 23444)
@@ -33,8 +33,8 @@
</pre>
<h3>requirements</h3>
<p>
-python >= 2.3<br>
-mercurial >= 0.9.x (for accessing pyFreenetHg's repository you need 0.9.3
or later)<br>
+python >= 2.4<br>
+mercurial >= 1.x<br>
pyFCP<br>
last not least: a running freenet node ;)<br />
optional: <a href="/USK at
MYLAnId-ZEyXhDGGbYOa1gOtkZZrFNTXjFl1dibLj9E,Xpu27DoAKKc8b0718E-ZteFrGqCYROe7XBBJI57pB4M,AQACAAE/SiteToolPlugin/0/"
target="_blank">SiteToolPlugin</a>
@@ -43,6 +43,7 @@
<p><a href="FreenetHg.py" target="_blank">download from here</a></p>
<p>hg clone|pull static-http://127.0.0.1:8888/USK at
fQGiK~CfI8zO4cuNyhPRLqYZ5TyGUme8lMiRnS9TCaU,E3S1MLoeeeEM45fDLdVV~n8PCr9pt6GMq0tuH4dRP7c,AQACAAE/freenethg/1/ /tmp/your/local/path</p>
<h3>install pyFreenetHg</h3>
+<p><b><i>Important hint:</i></b> Do not store url encoded keys into hgrc
(USK%40MY). Python does not like '%' here!</p>
<p>download <a href="FreenetHg.py" target="_blank">FreenetHg.py</a> and put it
somewhere.<br>
add the following to your <i>~/.hgrc</i>:
</p>
@@ -64,6 +65,7 @@
[freenethg]
inserturi = USK at foo,bar/Name/1
+requesturi = USK at oof,rab/Name/1
fcphost = 127.0.0.1
fcpport = 9481
</pre>
@@ -74,6 +76,7 @@
[freenethg]
inserturi = USK at foo,bar/Name/1
+requesturi = USK at oof,rab/Name/1
fcphost = 127.0.0.1
fcpport = 9481
uploadkeyword = triggerword
@@ -96,6 +99,57 @@
<p>way #2<br>
add the repository USK to your bookmarks, so you get notified if a new edition
is found</p>
+<h3>Commit notification over freenet</h3>
+
+<pre>
+[freenethg]
+notify = name name2 ...
+messagetemplate = /path/to/template # use for all notifies
+
+[notify_name]
+type = fmsnntp (in progress)
+messagetemplate = /path/to/template # per notify template
+....
+
+[notify_name2]
+type = fmsfcp (not yet)
+....
+
+[notify_name3]
+type = frost (not yet)
+....
+
+[notify_name4]
+type = freemail (not yet)
+....
+
+[notify_name5]
+type = freetalk (not yet)
+....
+
+</pre>
+
+<h3>Default index page</h3>
+The standard hg repository is not a regular freesite, so you get usually a<br>
+"Not in Archive" error if you access the repos uri in fproxy.<br>
+To resolve this problem, pyFreenetHg generates a simple index page.<br>
+ <br>
+You can provide your own html template by adding this option:<br>
+ <br>
+
+<pre>
+[freenethg]
+indextemplate = /path/to/template
+</pre>
+
+You can use variables in the template which will be replaced by
pyFreenetHg.<br>
+At the moment following variables are available:<br>
+ <br>
+<ul>
+<li> $uri - the URI of your repository
+<li> $fmsuser - your fms username, if provided in the config (see above)
+</ul>
+
<!-- h3>eclipse</h3>
<p>modified MercurialEclipse plugin (vectrace, 0.1.102) to fire
fcp-createstatic and fcp-updatestatic from within eclipse</p>
<p>use this key as eclipse update site or open it in your browser and download
& install it manually.</p>