Skip to content

Commit bdac4b6

Browse files
committed
config: Add extra_html option to add additional code to generated pages, for things like analytics.
1 parent a574116 commit bdac4b6

File tree

4 files changed

+23
-2
lines changed

4 files changed

+23
-2
lines changed

bin/pagegen.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ def producehtml(name, debug):
6969
<title>%s (Iris)</title>
7070
<meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
7171
<link rel="shortcut icon" type="image/png" href="%simages/favicon.png"/>
72+
%s
7273
%s%s
7374
%s
7475
%s
@@ -85,7 +86,7 @@ def producehtml(name, debug):
8586
</div>
8687
</body>
8788
</html>
88-
""" % (ui["doctype"], config.frontend["app_title"], config.frontend["static_base_url"], csshtml, customcss, jshtml, customjs, config.js_config(), ui["class"], div)
89+
""" % (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)
8990

9091
def main(outputdir=".", produce_debug=True):
9192
p = os.path.join(outputdir, "static")

iris.conf.example

+17
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,23 @@ network_name: FooNet
159159
# The title of the application in the web browser.
160160
app_title: %(network_name)s Web IRC
161161

162+
# EXTRA HTML: Additional HTML (e.g. analytics code) to place in the <head> of
163+
# generated documents. Note: For multi-line values, indent all the lines
164+
# after the first with at least one space or tab.
165+
extra_html: <script type="text/javascript">
166+
167+
var _gaq = _gaq || [];
168+
_gaq.push(['_setAccount', '*analytics account number here*']);
169+
_gaq.push(['_trackPageview']);
170+
171+
(function() {
172+
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
173+
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
174+
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
175+
})();
176+
177+
</script>
178+
162179
# INITIAL NICK: Default initial nickname for the user.
163180
# '.' characters will be replaced by random digits.
164181
# Leave blank to force the user to enter a nick before connecting.

qwebirc/config.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -123,9 +123,11 @@ def __interpret_config():
123123

124124

125125
def js_config():
126+
f = frontend.copy()
127+
del f["extra_html"] # already injected by pagegen.
126128
options = {
127129
'atheme': atheme,
128-
'frontend': frontend,
130+
'frontend': f,
129131
'ui': ui,
130132
}
131133
return json.dumps(options)

qwebirc/config_options.py

+1
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@
6363
("frontend", "base_url"),
6464
("frontend", "network_name"),
6565
("frontend", "app_title"),
66+
("frontend", "extra_html"),
6667
("frontend", "initial_nick"),
6768
("frontend", "initial_chans"),
6869
("frontend", "static_base_url"),

0 commit comments

Comments
 (0)