diff --git a/out/static/style.css b/out/static/style.css index 33daba6..794482c 100644 --- a/out/static/style.css +++ b/out/static/style.css @@ -49,7 +49,6 @@ footer .links { padding: 1em; } -#main-nav { float: right; padding: 0; } #main-nav li { display: inline-block; margin-right: 1em; } #main-nav img { height: 1.2em; margin: 0 -.4em; } #main-nav img:hover { transform: scale(1.2); } @@ -152,6 +151,7 @@ p.subtitle { margin-top: .2em; } .stick-top { top: 0; position: sticky; padding: .8em 0 .5em; background: #FFF; } .xscroll { overflow-x: scroll; max-width: 100%; } .yscroll { overflow-y: scroll; max-height: 80vh; } +.floatr, #main-nav { float: right; } table.alternate td, table.alternate th { padding: .5em; } table.alternate tr:nth-child(even) { background: #DDD; } table.alternate tr:nth-child(odd) { background: #F9F9F9; } diff --git a/src/README.md b/src/README.md index 1b7c4b4..0e8eb93 100644 --- a/src/README.md +++ b/src/README.md @@ -41,7 +41,6 @@ Given A → B, B depends on A ``` digraph Dependency { "." -> html_root - "." -> html_ranking "." -> download_itunes "." -> bundle_combine download_itunes -> index_app_names @@ -51,6 +50,7 @@ digraph Dependency { index_app_names -> index_rank index_app_names -> index_categories index_categories -> html_categories + html_categories -> html_ranking index_rank -> html_bundle index_rank -> html_index_domains index_domains -> html_index_domains diff --git a/src/html_categories.py b/src/html_categories.py index 28ef87a..6f2cb65 100755 --- a/src/html_categories.py +++ b/src/html_categories.py @@ -15,8 +15,11 @@ def process(affected=None, per_page=60): if affected and cid not in affected: continue out_dir = mylib.path_add(base, cid) - A = HTML.h2(HTML.a_path([(parent, '../')], cname)) - Z = HTML.p_download_json('data.json', 'category_{}.json'.format(cid)) + # full url since categories can have page 2, 3, etc. + A = '

' + HTML.a_path([(parent, '/category/')], cname) + \ + 'Ranking

' + Z = HTML.p_download_json('data.json', 'category-{}.json'.format(cid)) + # does BREAK html_ranking!! call html_categories before html_ranking _, a = HTML.write_app_pages(out_dir, json['apps'], cname, per_page, pre=A, post=Z) print(' {} ({})'.format(cname, a)) diff --git a/src/html_index_apps.py b/src/html_index_apps.py index 9193d59..8f6fa19 100755 --- a/src/html_index_apps.py +++ b/src/html_index_apps.py @@ -8,7 +8,7 @@ import index_app_names # get_sorted_app_names def process(per_page=60): print('generating html: app-index ...') title = 'Apps (A–Z)' - header = HTML.h2(HTML.a_path([('Results', '/results/')], title)) + header = '

' + HTML.a_path([('Results', '/results/')], title) + '

' p, a = HTML.write_app_pages(mylib.path_out('index', 'apps'), index_app_names.get_sorted_app_names(), title, per_page=per_page, pre=header) diff --git a/src/html_ranking.py b/src/html_ranking.py index 46670ec..da8f230 100755 --- a/src/html_ranking.py +++ b/src/html_ranking.py @@ -2,31 +2,59 @@ import lib_common as mylib import lib_html as HTML -import index_rank +import index_rank # fname_ranking_category, fname_ranking_all -def process(): - print('generating html: ranking ...') - title = 'Ranking' - header = HTML.a_path([('Results', '/results/')], title) - base = mylib.path_out('ranking') - HTML.write(base, f''' -

{header}

+def html_base(*pathlist): + return ''' +

{}

- This ranking shows only the 500 most recently updated applications.
+ 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.

Loading …
-{ HTML.p_download_json('data.json', 'ranking-all.json') } +'''.format(HTML.a_path(pathlist, 'Ranking')) + + +def html_script_chunk(fname): + return ''' ''', title=title) - mylib.symlink(index_rank.fname_ranking_list(), + rank_js('{}'); +'''.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', + 'results-category-{}.json'.format(cid)) + src += html_script_chunk('data.json') + HTML.write(base, src, title='Category Ranking: ' + category_name) + mylib.symlink(index_rank.fname_ranking_category(cid), mylib.path_add(base, 'data.json')) + + +def write_ranking_all(title, base_dir): + src = html_base(('Results', '/results/')) + src += HTML.p_download_json('data.json', 'results-all.json') + src += html_script_chunk('data.json') + HTML.write(base_dir, src, title=title) + mylib.symlink(index_rank.fname_ranking_all(), + mylib.path_add(base_dir, 'data.json')) + + +def process(): + print('generating html: ranking ...') + write_ranking_all('Ranking', mylib.path_out('ranking')) + for _, json in mylib.enum_categories(): + cid, name = json['meta'] + write_ranking_category(cid, name) print('') diff --git a/src/index_categories.py b/src/index_categories.py index 891c2e2..8a9e221 100755 --- a/src/index_categories.py +++ b/src/index_categories.py @@ -21,6 +21,16 @@ def fname_cat_name_compact(): return mylib.path_data_index('category_names_compact.json') +def fname_cat_individual(cid): + return mylib.path_data_index('category', 'id_{}.json'.format(cid)) + + +def make_dir_individuals(): + pth = mylib.path_data_index('category') + mylib.rm_dir(pth) + mylib.mkdir(pth) + + def load_json_if_not_already(noNames=False): global _dict_apps, _dict_names if not _dict_apps: @@ -85,11 +95,9 @@ def persist_individual_files(): return ret index = sorted_reverse_index() - pth = mylib.path_data_index('category') - mylib.rm_dir(pth) - mylib.mkdir(pth) + make_dir_individuals() for cid, cname in _dict_names.items(): - mylib.json_write(mylib.path_add(pth, 'id_{}.json'.format(cid)), + mylib.json_write(fname_cat_individual(cid), {'meta': [cid, cname], 'apps': index[cid]}) diff --git a/src/index_rank.py b/src/index_rank.py index f17d199..b31c0db 100755 --- a/src/index_rank.py +++ b/src/index_rank.py @@ -16,8 +16,19 @@ def fname_app_rank(): return mylib.path_data_index('app_rank.json') -def fname_ranking_list(): - return mylib.path_data_index('ranking_list.json') +def fname_ranking_all(): + return mylib.path_data_index('ranking_all.json') + + +def fname_ranking_category(cid): + return mylib.path_data_index('rank', 'id_{}.json'.format(cid)) + + +def make_dir_individuals(reset=False): + pth = mylib.path_data_index('rank') + if reset: + mylib.rm_dir(pth) + mylib.mkdir(pth) def json_to_list(json): @@ -75,10 +86,7 @@ def write_ranking_category_list(index, affected_ids): return True return False - pth = mylib.path_data_index('rank') - if reset: - mylib.rm_dir(pth) - mylib.mkdir(pth) + make_dir_individuals(reset) for _, json in mylib.enum_categories(): cid, cname = json['meta'] ids = [bid for bid, _ in json['apps']] @@ -90,8 +98,7 @@ def write_ranking_category_list(index, affected_ids): ret.append(x) if len(ids) == 0 or len(ret) >= MAX_RANKING_LIMIT: break - mylib.json_write(mylib.path_add(pth, 'id_{}.json'.format(cid)), - ret, pretty=False) + mylib.json_write(fname_ranking_category(cid), ret, pretty=False) def write_ranking_list(index, affected_ids): @@ -105,7 +112,7 @@ def write_ranking_list(index, affected_ids): if len(ret) > MAX_RANKING_LIMIT: # limit to most recent X entries ret = ret[:MAX_RANKING_LIMIT] # mylib.sort_by_name(ret, 1) - mylib.json_write(fname_ranking_list(), ret, pretty=False) + mylib.json_write(fname_ranking_all(), ret, pretty=False) def write_rank_index(index): diff --git a/src/lib_html.py b/src/lib_html.py index a9d8e1e..50bbe0d 100755 --- a/src/lib_html.py +++ b/src/lib_html.py @@ -57,10 +57,6 @@ def div(inner, attr=None): return xml('div', inner, attr) -def h2(inner, attr=None): - return xml('h2', inner, attr) - - def a_path(parts, suffix): ''' expects (name, url) tuples ''' return ' / '.join(['{}'.format(url, title) diff --git a/src/main.py b/src/main.py index 26829f3..9641fac 100755 --- a/src/main.py +++ b/src/main.py @@ -10,6 +10,7 @@ import html_bundle import html_categories import html_index_apps import html_index_domains +import html_ranking import html_root import index_app_names import index_categories @@ -35,9 +36,10 @@ def rebuild_html(bundle_ids=None, cat_ids=None, inclIApp=True, inclRoot=False): if bundle_ids: html_bundle.process(bundle_ids) # after index_rank html_categories.process(affected=cat_ids) # after index_categories - html_index_domains.process() # after index_domains + html_ranking.process() # after html_categories + html_index_domains.process() # after index_domains & index_rank if inclIApp: - html_index_apps.process() + html_index_apps.process() # after index_categories else: print('no new bundle, not rebuilding index') if inclRoot: # TODO: remove check if root contains dynamic content @@ -73,7 +75,7 @@ def combine_and_update(bundle_ids): # 3. re-calculate combined.json bundle_combine.process(bundle_ids) # 4. re-build indices - index_rank.process(bundle_ids) # after bundle_combine + index_rank.process(bundle_ids) # after bundle_combine & index_app_names index_domains.process(bundle_ids) # after bundle_combine # 5. make all html files rebuild_html(bundle_ids, inclIApp=len(new_ids) > 0) diff --git a/src/z_dependency.svg b/src/z_dependency.svg index d2e6d3e..57131a4 100644 --- a/src/z_dependency.svg +++ b/src/z_dependency.svg @@ -1,149 +1,149 @@ - - + + Dependency - + . - -. + +. html_root - -html_root + +html_root .->html_root - - - - -html_ranking - -html_ranking - - -.->html_ranking - - + + -download_itunes - -download_itunes +download_itunes + +download_itunes -.->download_itunes - - +.->download_itunes + + -bundle_combine - -bundle_combine +bundle_combine + +bundle_combine -.->bundle_combine - - +.->bundle_combine + + download_tracker - -download_tracker + +download_tracker .->download_tracker - - + + -index_app_names - -index_app_names +index_app_names + +index_app_names -download_itunes->index_app_names - - +download_itunes->index_app_names + + -index_rank - -index_rank +index_rank + +index_rank -bundle_combine->index_rank - - +bundle_combine->index_rank + + -index_domains - -index_domains +index_domains + +index_domains -bundle_combine->index_domains - - +bundle_combine->index_domains + + -index_app_names->index_rank - - +index_app_names->index_rank + + -index_categories - -index_categories +index_categories + +index_categories -index_app_names->index_categories - - +index_app_names->index_categories + + html_bundle - -html_bundle + +html_bundle index_rank->html_bundle - - + + html_index_domains - -html_index_domains + +html_index_domains index_rank->html_index_domains - - + + index_domains->html_index_domains - - + + -html_index_apps - -html_index_apps +html_index_apps + +html_index_apps -index_categories->html_index_apps - - +index_categories->html_index_apps + + -html_categories - -html_categories +html_categories + +html_categories -index_categories->html_categories +index_categories->html_categories + + + + +html_ranking + +html_ranking + + +html_categories->html_ranking diff --git a/templates/base.html b/templates/base.html index a2f4182..1d6f1ce 100644 --- a/templates/base.html +++ b/templates/base.html @@ -3,9 +3,9 @@ - + #_TITLE_#AppCheck: Privacy Monitor - +