Skip to content

Commit

Permalink
config: Add extra_html option to add additional code to generated pag…
Browse files Browse the repository at this point in the history
…es, for things like analytics.
  • Loading branch information
kbuck1 committed Jun 5, 2012
1 parent a574116 commit bdac4b6
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 2 deletions.
3 changes: 2 additions & 1 deletion bin/pagegen.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ def producehtml(name, debug):
<title>%s (Iris)</title>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
<link rel="shortcut icon" type="image/png" href="%simages/favicon.png"/>
%s
%s%s
%s
%s
Expand All @@ -85,7 +86,7 @@ def producehtml(name, debug):
</div>
</body>
</html>
""" % (ui["doctype"], config.frontend["app_title"], config.frontend["static_base_url"], csshtml, customcss, jshtml, customjs, config.js_config(), ui["class"], div)
""" % (ui["doctype"], config.frontend["app_title"], config.frontend["static_base_url"], config.frontend["extra_html"], csshtml, customcss, jshtml, customjs, config.js_config(), ui["class"], div)

def main(outputdir=".", produce_debug=True):
p = os.path.join(outputdir, "static")
Expand Down
17 changes: 17 additions & 0 deletions iris.conf.example
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,23 @@ network_name: FooNet
# The title of the application in the web browser.
app_title: %(network_name)s Web IRC

# EXTRA HTML: Additional HTML (e.g. analytics code) to place in the <head> of
# generated documents. Note: For multi-line values, indent all the lines
# after the first with at least one space or tab.
extra_html: <script type="text/javascript">

var _gaq = _gaq || [];
_gaq.push(['_setAccount', '*analytics account number here*']);
_gaq.push(['_trackPageview']);

(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();

</script>

# INITIAL NICK: Default initial nickname for the user.
# '.' characters will be replaced by random digits.
# Leave blank to force the user to enter a nick before connecting.
Expand Down
4 changes: 3 additions & 1 deletion qwebirc/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,11 @@ def __interpret_config():


def js_config():
f = frontend.copy()
del f["extra_html"] # already injected by pagegen.
options = {
'atheme': atheme,
'frontend': frontend,
'frontend': f,
'ui': ui,
}
return json.dumps(options)
Expand Down
1 change: 1 addition & 0 deletions qwebirc/config_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
("frontend", "base_url"),
("frontend", "network_name"),
("frontend", "app_title"),
("frontend", "extra_html"),
("frontend", "initial_nick"),
("frontend", "initial_chans"),
("frontend", "static_base_url"),
Expand Down

0 comments on commit bdac4b6

Please sign in to comment.