Przeglądaj źródła

Format protection level nicely.

master
Ben Kurtovic 8 lat temu
rodzic
commit
ff0481a062
3 zmienionych plików z 20 dodań i 6 usunięć
  1. +8
    -2
      static/style.css
  2. +7
    -3
      templates/index.mako
  3. +5
    -1
      tif/calc.py

+ 8
- 2
static/style.css Wyświetl plik

@@ -8,6 +8,12 @@ footer {}

#result {}

#result-page {}

#result-cache {}

.result-page {}

.prot-level {}

.prot-expiry {}

.prot-none {}

+ 7
- 3
templates/index.mako Wyświetl plik

@@ -20,7 +20,7 @@

% if "tif" in result:
<div id="result">
<div id="result-page"><a href="${result['page'].url}">${result["page"].title | h}</a></div>
<div class="result-page"><a href="${result['page'].url}">${result["page"].title | h}</a></div>
<table>
<tr>
<td>TIF</td>
@@ -32,10 +32,14 @@
</tr>
<tr>
<td>Protection</td>
<td>${result["protection"]}</td>
% if result["protection"]:
<td><span class="prot-level prot-${result['protection']['level']}">${result["protection"]["level"]}</span> until <span class="prot-expiry">${result["protection"]["expiry"]}</span></td>
% else:
<td><span class="prot-none">None</span></td>
% endif
</tr>
</table>
% if "cache" in result and result["cache"]:
% if "cache_time" in result:
<div id="result-cache">Pageview data is cached from up to <abbr title="${result['cache_time']}">${result["cache_age"]} ago</abbr>.</div>
% endif
</div>


+ 5
- 1
tif/calc.py Wyświetl plik

@@ -109,6 +109,10 @@ def _format_time(cache_time):
return formatter(diff.seconds / 60, "minute")
return formatter(diff.seconds, "second")

def _get_protection(page):
edit = [prot for prot in page.protection if prot["type"] == "edit"]
return edit or None

def calculate_tif(title):
bot = Bot(".earwigbot")
db = _get_db(bot)
@@ -124,7 +128,7 @@ def calculate_tif(title):

result["tif"] = tif
result["transclusions"] = transclusions
result["protection"] = page.protection
result["protection"] = _get_protection(page)
if cache_time:
result["cache_time"] = cache_time.strftime("%b %d, %Y %H:%M:%S UTC")
result["cache_ago"] = _format_time(cache_time)


Ładowanie…
Anuluj
Zapisz