Bug 3734 - [HGWEB] web.templates not used in multi repo list
Summary: [HGWEB] web.templates not used in multi repo list
Status: RESOLVED FIXED
Alias: None
Product: Mercurial
Classification: Unclassified
Component: hgweb (show other bugs)
Version: earlier
Hardware: All All
: normal bug
Assignee: Bugzilla
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-12-15 13:25 UTC by Damien Couderc
Modified: 2017-11-01 18:05 UTC (History)
2 users (show)

See Also:
Python Version: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Damien Couderc 2012-12-15 13:25 UTC
Hi,
when using web.templates to set an alternative directory for templates the new themes are not used when displaying the repositories.
More precisely, the CSS file is not found.

If I copy the CSS file in the system directory then it is found by hgweb.
Comment 1 Damien Couderc 2012-12-15 13:56 UTC
More information :
The bug only appears on the index page which share the same header template that contains the link to the CSS file.
Others templates work fine with the same header.
Comment 2 Matt Mackall 2012-12-19 16:50 UTC
Can you show us your config file?
Comment 3 Damien Couderc 2012-12-22 09:31 UTC
Here it is :
[paths]
/prj1 = /hg/repos/prj1
/prj2 = /hg/repos/prj2

[web]
templates = /hg/templates
style = rounded
allow_push = hguser
allow_archive = gz

The bug should be easy to reproduce by copying an existing theme and renaming it's directory name and css file (don't forget to change the css name in the header template).

I'll join my new theme if needed.
Comment 4 Matt Mackall 2012-12-22 19:28 UTC
I see. Turns out hgwebdir handles static paths differently. Try this fix:

diff -r 40cc411346d1 mercurial/hgweb/hgwebdir_mod.py
--- a/mercurial/hgweb/hgwebdir_mod.py	Thu Dec 20 19:22:12 2012 +0100
+++ b/mercurial/hgweb/hgwebdir_mod.py	Sat Dec 22 18:09:45 2012 -0600
@@ -184,7 +184,13 @@
                         fname = virtual[7:]
                     else:
                         fname = req.form['static'][0]
-                    static = templater.templatepath('static')
+                    static = self.ui.config("web", "static", None,
+                                            untrusted=False)
+                    if not static:
+                        tp = self.templatepath or templater.templatepath()
+                        if isinstance(tp, str):
+                            tp = [tp]
+                        static = [os.path.join(p, 'static') for p in tp]
                     return (staticfile(static, fname, req),)
 
                 # top-level index
Comment 5 Damien Couderc 2012-12-24 04:54 UTC
(In reply to comment #4)

It works fine :)
Comment 6 HG Bot 2013-01-02 01:49 UTC
Fixed by http://selenic.com/repo/hg/rev/e4f17956f45a
Matt Mackall <mpm@selenic.com>
hgwebdir: honor web.templates and web.static for static files (issue3734)

(please test the fix)