Skip to content

Commit

Permalink
Add registry subdomain and suspensions page openrightsgroup/Blocking-…
Browse files Browse the repository at this point in the history
  • Loading branch information
dantheta committed Apr 5, 2021
1 parent f04bd54 commit c4addb8
Show file tree
Hide file tree
Showing 5 changed files with 104 additions and 5 deletions.
46 changes: 46 additions & 0 deletions BlockedFrontend/registry.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import os
import re
import psycopg2
import logging
import datetime
import itertools

from flask import Blueprint, render_template, redirect, request, \
g, url_for, abort, config, current_app, session, flash, jsonify, Response

from models import *
from auth import *
from utils import *
from resources import *
from db import *

import NORM
from NORM.exceptions import ObjectNotFound,ObjectExists

registry_pages = Blueprint('registry', __name__, template_folder='templates/registry')


@registry_pages.route('/')
@registry_pages.route('/suspensions')
@registry_pages.route('/suspensions/<int:page>')
def registry_suspensions(page=1):
pagesize = 25
offset = (page-1)*pagesize

res = NORM.Query(g.conn, "select count(*), max(created) from public.registry_suspension_urls", [])
row = res.fetchone()
count = row[0]
pagecount = get_pagecount(count, pagesize)
newdate = row[1]

sql = "select * from public.registry_suspension_urls limit {0} offset {1}".format(pagesize, offset)
print sql
suspensions = NORM.Query(g.conn, sql, [])
g.conn.commit()
return render_template('registry_suspensions.html',
suspensions=suspensions,
page=page,
count=count,
newdate=newdate,
pagesize=pagesize,
pagecount=pagecount)
4 changes: 4 additions & 0 deletions BlockedFrontend/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,13 @@
from stats import stats_pages
app.register_blueprint(stats_pages, subdomain=www_domain)

from registry import registry_pages
app.register_blueprint(registry_pages, subdomain=app.config['SUBDOMAIN_NOMINET'])

from cmsassets import cms_assets
app.register_blueprint(cms_assets, subdomain=www_domain)
app.register_blueprint(cms_assets, subdomain=app.config['SUBDOMAIN_INJUNCTIONS'])
app.register_blueprint(cms_assets, subdomain=app.config['SUBDOMAIN_NOMINET'])

@app.before_first_request
def setup_db():
Expand Down
2 changes: 2 additions & 0 deletions BlockedFrontend/templates/blocked-uk/BasicPage.page.html
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,9 @@

<div class="row">
<div class="col-md-12 menu">
{% block main_menu %}
{{ chunks.main_menu() }}
{% endblock %}
</div>
</div>

Expand Down
17 changes: 12 additions & 5 deletions BlockedFrontend/templates/chunks.part.html
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,12 @@ <h3>Spread the word</h3>

{% endmacro %}

{% macro registry_menu() %}
<a class="{{ 'active' if request.path == '/' else ''}}" href="/">Home</a>
{{ menu_link('Registry Suspensions', '/suspensions') }}
{{ menu_link('Domain Seizures', '/seizures') }}
{% endmacro %}

{% macro piwik() %}
<!-- Matomo -->
{% if config.PIWIK %}
Expand All @@ -117,13 +123,14 @@ <h3>Spread the word</h3>
{% endmacro %}

{% macro footer_menu() %}
{% set default_vhost = [request.scheme, "://", config.SUBDOMAIN_MAIN, ".", config.SERVER_NAME]|join('') %}
<a class="" href="https://action.openrightsgroup.org/sign-up-for-org-email-updates">Stay in touch</a>
<!-- <a class="" href="/support">Support</a> -->
<a class="" href="/credits">Credits</a>
<a class="" href="/stats/probes">Probe Status</a>
<a class="" href="/legal-blocks">Court Ordered Blocks</a>
<a class="" href="/dea-blocking-orders">Age-verification Blocks</a>
<a class="" href="/support">Get involved</a>
<a class="" href="{{ default_vhost }}/credits">Credits</a>
<a class="" href="{{ default_vhost }}/stats/probes">Probe Status</a>
<a class="" href="{{ default_vhost }}/legal-blocks">Court Ordered Blocks</a>
<a class="" href="{{ default_vhost }}/dea-blocking-orders">Age-verification Blocks</a>
<a class="" href="{{ default_vhost }}/support">Get involved</a>
<a class="" href="https://www.openrightsgroup.org/donate/">Donate</a>
<a class="" href="https://www.openrightsgroup.org/contact/">Contact</a>
<a class="" href="https://www.openrightsgroup.org/privacy/">Privacy Policy</a>
Expand Down
40 changes: 40 additions & 0 deletions BlockedFrontend/templates/registry/registry_suspensions.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{% extends "BasicPage.page.html" %}
{%import "remotecontent.part.html" as rmt %}
{%import "paging.part.html" as paging %}

{% set pagetitle = "Registry suspensions" %}

{%block banner_text %}
{% call rmt.remote('banner_text') %}
Domains that have been suspended by their registrar
{% endcall %}
{% endblock %}

{% block main_menu %}
{{ chunks.registry_menu() }}
{% endblock %}

{% block body %}

<h3>{{ count }} suspended domain{{ '' if count == 1 else 's' }} found</h3>

<table class="table">
<tr>
<th>Domain</th>
<th>Registrar</th>
<th>Detected</th>
<th>Last Seen</th>
</tr>
{% for row in suspensions %}
<tr>
<td>{{ row.url|noproto }} </td>
<td>{{ row.registry|title }}</td>
<td>{{ row.created|fmdate }} {% if row.created == newdate %}<span class="label label-info">New</span>{% endif %}</td>
<td>{{ row.lastseen|fmdate }}</td>
</tr>
{% endfor %}

</table>
{{ paging.page_list('.registry_suspensions', page, pagecount, pagesize) }}

{% endblock %}

0 comments on commit c4addb8

Please sign in to comment.