diff --git a/out/static/style.css b/out/static/style.css index a106086..e874517 100644 --- a/out/static/style.css +++ b/out/static/style.css @@ -30,6 +30,7 @@ header h1 { margin-top: 0; } header h1 span { font-size: .7em; color: silver; } +header ul { padding: 0; } main { padding: .1em 2em 1.5em; background: #fff; diff --git a/src/html_ranking.py b/src/html_ranking.py index ac75fd6..cdcffec 100755 --- a/src/html_ranking.py +++ b/src/html_ranking.py @@ -2,61 +2,109 @@ import lib_common as mylib import lib_html as HTML -import index_rank # fname_ranking_category, fname_ranking_all +import index_rank # fname_rank_list, fname_ranking_all -def html_base(*pathlist): +def html_h2_path(pathlist, title='Ranking'): + return '

{}

'.format(HTML.a_path(pathlist, title)) + + +def html_default_description(): return ''' -

{}

This ranking shows only 500 of the most recently updated applications.
If you're missing an app, feel free to contribute a new app recording. -

+

''' + + +def html_table(): + return '''
Loading …
-
-'''.format(HTML.a_path(pathlist, 'Ranking')) +''' -def html_script_chunk(fname): +def html_script_chunk(fname, sort_col, sort_order): return ''' '''.format(fname) - - -def write_ranking_category(cid, category_name): - base = mylib.path_out('category', cid, 'ranking') - # full urls since categories can have page 2, 3, etc. - src = html_base(('All Categories', '/category/'), - (category_name, '/category/{}/'.format(cid))) - src += HTML.p_download_json('data.json', - 'raw-category-{}.json'.format(cid)) - src += html_script_chunk('data.json') - HTML.write(base, src, title='Category Ranking: ' + category_name) - mylib.symlink(index_rank.fname_rank_list('category', cid), - mylib.path_add(base, 'data.json')) + rank_js('{}', {}, {}); +'''.format(fname, sort_col, sort_order) def write_ranking_all(title, base_dir): # full urls since app index can have page 2, 3, etc. - src = html_base(('Results', '/results/'), - ('Apps (A–Z)', '/index/apps/')) + src = html_h2_path([('Results', '/results/'), + ('Apps (A–Z)', '/index/apps/')]) + src += html_default_description() + src += html_table() src += HTML.p_download_json('data.json', 'raw-apps.json') - src += html_script_chunk('data.json') + src += html_script_chunk('data.json', 12, -1) # last update desc HTML.write(base_dir, src, title=title) mylib.symlink(index_rank.fname_ranking_all(), mylib.path_add(base_dir, 'data.json')) +def write_ranking_category(cid, category_name): + base = mylib.path_out('category', cid, 'ranking') + # full urls since categories can have page 2, 3, etc. + src = html_h2_path([('All Categories', '/category/'), + (category_name, '/category/{}/'.format(cid))]) + src += html_default_description() + src += html_table() + src += HTML.p_download_json('data.json', + 'raw-category-{}.json'.format(cid)) + src += html_script_chunk('data.json', 12, -1) # last update desc + HTML.write(base, src, title='Category Ranking: ' + category_name) + mylib.symlink(index_rank.fname_rank_list('category', cid), + mylib.path_add(base, 'data.json')) + + +def write_ranking_custom_lists(base_dir, list_id, list_name, parent_title): + base = mylib.path_add(base_dir, list_id) + src = html_h2_path([('Results', '/results/'), + (parent_title, '/lists/')], list_name) + src += html_table() + src += HTML.p_download_json('data.json', + 'raw-list-{}.json'.format(list_id)) + src += html_script_chunk('data.json', 9, 1) # tracker percent asc + HTML.write(base, src, title='Compare: ' + list_name) + mylib.symlink(index_rank.fname_rank_list('custom', list_id), + mylib.path_add(base, 'data.json')) + + def process(): print('generating html: ranking ...') + print(' overall ranking') write_ranking_all('Ranking', mylib.path_out('index', 'apps', 'ranking')) + + print(' category ranking') for _, json in mylib.enum_categories(): cid, name = json['meta'] write_ranking_category(cid, name) + + print(' custom lists') + base_custom = mylib.path_out('lists') + title_custom = 'Lists' + arr = [] + for list_id, json in mylib.enum_custom_lists(): + list_name = json['name'] + arr.append((list_id, list_name, len(json['apps']))) + write_ranking_custom_lists(base_custom, list_id, list_name, + parent_title=title_custom) + + print(' index page') + mylib.sort_by_name(arr, 1) + src = html_h2_path([('Results', '/results/')], title_custom) + src += ''' +

+ We present selected lists of apps that have been added to AppCheck. +

+
''' + for x in arr: + src += '

{} contains {} apps

\n'.format(*x) + HTML.write(base_custom, src + '
', title=title_custom) print('') diff --git a/src/html_root.py b/src/html_root.py index 1e12ffa..ecad5e7 100755 --- a/src/html_root.py +++ b/src/html_root.py @@ -93,6 +93,7 @@ def gen_results(base_dir, c_apps, c_domains, title):
  • List of Requested Domains
  • List of Trackers
  • +

    Or compare similar application via custom comparison Lists.

    '''.format(title, c_apps, c_domains, c_recs, c_logs), title=title) mylib.symlink(index_rank.fname_app_rank(), mylib.path_add(base_dir, 'rank.json')) # after HTML.write @@ -116,4 +117,4 @@ def process(app_count, dom_count, inclStatic=False): if __name__ == '__main__': - process() + process(-1, -1) diff --git a/src/index_rank.py b/src/index_rank.py index ec30653..f6eba41 100755 --- a/src/index_rank.py +++ b/src/index_rank.py @@ -112,11 +112,12 @@ def write_ranking_list(index, affected_ids): del(values[8:]) # prepare for write_rank_index print(' write custom lists') + # sort by %-tracker asc, #-pardom asc, avg-req-per-min asc + ret.sort(key=lambda x: (x[2 + 7], x[2 + 5], x[2 + 3])) write_ranking_custom_lists(ret, affected_ids) - ret.sort(key=lambda x: -x[2 + 10]) # sort by last update - print(' write category lists') + ret.sort(key=lambda x: -x[2 + 10]) # sort by last update desc write_ranking_category_list(ret, affected_ids) if len(ret) > MAX_RANKING_LIMIT: # limit to most recent X entries ret = ret[:MAX_RANKING_LIMIT] diff --git a/src/lib_common.py b/src/lib_common.py index 5c7000c..fa2a1b9 100755 --- a/src/lib_common.py +++ b/src/lib_common.py @@ -248,9 +248,9 @@ def enum_newly_added(): def enum_custom_lists(): - for fname in glob.glob(path_data('_lists', 'id_*.json')): + for fname in glob.glob(path_data('_lists', 'list_*.json')): with open(fname, 'r') as fp: - yield os.path.basename(fname)[3:-5], json.load(fp) + yield os.path.basename(fname)[5:-5], json.load(fp) def enum_jsons(bundle_id):