Quellcode durchsuchen

Show warning when a page has an attribution template.

copyvios-ng
Ben Kurtovic vor 7 Jahren
Ursprung
Commit
63f1ae98c4
3 geänderte Dateien mit 48 neuen und 0 gelöschten Zeilen
  1. +34
    -0
      copyvios/attribution.py
  2. +5
    -0
      static/style.css
  3. +9
    -0
      templates/index.mako

+ 34
- 0
copyvios/attribution.py Datei anzeigen

@@ -0,0 +1,34 @@
# -*- coding: utf-8 -*-

from __future__ import unicode_literals

from earwigbot.wiki import NS_TEMPLATE

__all__ = ["get_attribution_info"]

ATTRIB_TEMPLATES = {
"enwiki": {
"CC-notice", "Cc-notice",
"Citation-attribution",
"Free-content attribution", "Open-source attribution",
"Source-attribution",
}
}

def get_attribution_info(site, page):
"""Check to see if the given page has some kind of attribution info.

If yes, return a mwparserfromhell.nodes.Template object for the attribution
template. If no, return None.
"""
if site.name not in ATTRIB_TEMPLATES:
return None

templates = ATTRIB_TEMPLATES[site.name]
prefix = site.namespace_id_to_name(NS_TEMPLATE)
templates |= {prefix + ":" + tmpl for tmpl in templates if ":" not in tmpl}

for template in page.parse().ifilter_templates():
if template.name.matches(templates):
return template
return None

+ 5
- 0
static/style.css Datei anzeigen

@@ -68,6 +68,11 @@ div#cv-result {
margin: 10px 5px;
}

div#attribution-warning {
padding: 5px;
margin: 15px 5px 10px 5px;
}

div#turnitin-container {
padding: 5px;
margin: 15px 5px 10px 5px;


+ 9
- 0
templates/index.mako Datei anzeigen

@@ -4,6 +4,7 @@
from copyvios.misc import cache
%>\
<%include file="/support/header.mako" args="title='Earwig\'s Copyvio Detector'"/>
<%namespace module="copyvios.attribution" import="get_attribution_info"/>\
<%namespace module="copyvios.highlighter" import="highlight_delta"/>\
<%namespace module="copyvios.misc" import="httpsfix, urlstrip"/>\
% if notice:
@@ -211,6 +212,14 @@
</table>
</div>

<% attrib = get_attribution_info(query.site, query.page) %>
% if attrib:
<% attrib_page = query.site.get_page(attrib.name) %>
<div id="attribution-warning" class="yellow-box">
This article contains an attribution template: <tt>{{<a href="attrib_page.url">${attrib_page.title | h}</a>}}</tt>. Please verify that any potential copyvios are not from properly attributed sources.
</div>
% endif

% if query.turnitin_result:
<div id="turnitin-container" class="${'red' if query.turnitin_result.reports else 'green'}-box">
<div id="turnitin-title">Turnitin Results</div>


Laden…
Abbrechen
Speichern