def gen_and_link_groupby(cluster_id, base, raw_fname='data'): json_file = index_rank.fname_rank_list('groupby', cluster_id) raw_fname += '.json' mylib.symlink(json_file, mylib.path_add(base, raw_fname)) named_download = 'compare-{}.json'.format(cluster_id) return prefill_groupby_table(json_file) + HTML.p_download_json( raw_fname, named_download)
def process(affected=None, per_page=60): print('generating html: category-index ...') base = mylib.path_out('category') parent = 'All Categories' arr = [] for fname, json in mylib.enum_categories(): cid, cname = json['meta'] arr.append([cid, cname]) if affected and cid not in affected: continue out_dir = mylib.path_add(base, cid) # full url since categories can have page 2, 3, etc. A = HTML.h2_path_n_rank(cname, [('/category/', parent)], 'ranking/') Z = HTML.p_download_json('data.json', 'category-{}.json'.format(cid)) _, a = HTML.write_app_pages(out_dir, json['apps'], cname, per_page, pre=A, post=Z) # write_app_pages breaks html_ranking!! call html_ranking after this! print(' {} ({})'.format(cname, a)) if a > 1: arr[-1][-1] += ' ({})'.format(a) # append count mylib.symlink(fname, mylib.path_add(out_dir, 'data.json')) print(' .. {} categories'.format(len(arr))) write_overview_page(base, arr, parent) print('')
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'), ('/lists/', parent_title)], 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 write_ranking_all(title, base_dir): # full urls since app index can have page 2, 3, etc. src = html_h2_path([('/results/', 'Results'), ('/index/apps/', 'Apps (A–Z)')]) src += html_default_description() src += html_table() src += HTML.p_download_json('data.json', 'raw-apps.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([('/category/', 'All Categories'), ('/category/{}/'.format(cid), category_name)]) 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'))