Browse Source

Implement 'background' option plus background images.

pull/24/head
Ben Kurtovic 12 years ago
parent
commit
1523c2401f
6 changed files with 31 additions and 8 deletions
  1. +21
    -3
      pages/settings.mako
  2. +1
    -1
      pages/support/footer.mako
  3. +2
    -2
      pages/support/header.mako
  4. BIN
     
  5. +1
    -1
      static/js/potd.js
  6. +6
    -1
      toolserver/settings.py

+ 21
- 3
pages/settings.mako View File

@@ -40,9 +40,27 @@
<tt>.org</tt> <tt>.org</tt>
</td> </td>
</tr> </tr>
<tr>
<td>Background:</td>
</tr>
<%
background_options = [
("plain-brown", "Use a plain tiled background (brown version)."),
("plain-blue", "Use a plain tiled background (blue version)."),
("potd", 'Use the current <a href="//commons.wikimedia.org/">Wikimedia Commons</a> <a href="//commons.wikimedia.org/wiki/Commons:Picture_of_the_day">Picture of the Day</a>, unfiltered. Certain POTDs may be unsuitable as backgrounds due to their aspect ratio or subject matter (generally portraits do not work well).'),
("list", 'Randomly select from <a href="http://commons.wikimedia.org/wiki/User:The_Earwig/POTD">a subset of previous Commons Pictures of the Day</a> that work well as widescreen backgrounds, refreshed daily (default).'),
]
selected = cookies["EarwigBackground"].value if "EarwigBackground" in cookies else None
%>
% for i, (value, desc) in enumerate(background_options):
<tr>
% if i == 0:
<td>Background:</td>
% else:
<td>&nbsp;</td>
% endif
<td>
<input type="radio" name="background" value="${value}" "${'checked' if option == elected else ''}" /> ${desc}
</td>
</tr>
% endfor
<tr> <tr>
<td><button type="submit">Save</button></td> <td><button type="submit">Save</button></td>
</tr> </tr>


+ 1
- 1
pages/support/footer.mako View File

@@ -31,4 +31,4 @@
</table> </table>
</div> </div>
</body> </body>
</html>
</html>

+ 2
- 2
pages/support/header.mako View File

@@ -31,8 +31,8 @@
% if "EarwigBackground" in cookies: % if "EarwigBackground" in cookies:
% if cookies["EarwigBackground"].value == "list": % if cookies["EarwigBackground"].value == "list":
<body onload="set_background_list()"> <body onload="set_background_list()">
% elif cookies["EarwigBackground"].value == "plain":
<body style="background-image: url('${root}/static/images/background.png');">
% elif cookies["EarwigBackground"].value in ["plain-brown", "plain-blue"]:
<body style="background-image: url('${root}/static/images/background-${cookies['EarwigBackground'].value[6:]}.png');">
% else % else
<body onload="set_background_potd()"> <body onload="set_background_potd()">
% endif % endif


BIN
View File


+ 1
- 1
static/js/potd.js View File

@@ -87,7 +87,7 @@ function parse_list_file_name(data) {
} }


var filenames = []; var filenames = [];
while ((match = /\*\s*\[\[File:(.*?)\]\]/g.exec(content)) !== null) {
while ((match = /\*\s*\[\[:File:(.*?)\]\]/g.exec(content)) !== null) {
filenames.push(match[1]); filenames.push(match[1]);
} }
var filename = filenames[Math.floor(Math.random() * filenames.length)]; var filename = filenames[Math.floor(Math.random() * filenames.length)];


+ 6
- 1
toolserver/settings.py View File

@@ -32,8 +32,13 @@ def _do_set(query, headers, cookies):
if key not in cookies or cookies[key].value != query.project: if key not in cookies or cookies[key].value != query.project:
set_cookie(headers, cookies, key, query.project, 365) set_cookie(headers, cookies, key, query.project, 365)
changes.add("site") changes.add("site")
if query.background:
key = "EarwigBackground"
if key not in cookies or cookies[key].value != query.background:
set_cookie(headers, cookies, key, query.background, 365)
changes.add("background")
if changes: if changes:
changes = ", ".format(changes)
changes = ", ".format(sorted(list(changes)))
return "Updated {0}.".format(changes) return "Updated {0}.".format(changes)
return None return None




Loading…
Cancel
Save