def browse_organizations(): '''Browse all organizations in MarkLogic.''' click.echo( json.dumps( get_collections( *server_args + ('https://bmrc.lib.uchicago.edu/organizations/', ))))
def browse(): b = request.args.get('b', default='', type=str) page = request.args.get('page', default=1, type=int) sort = request.args.get('sort', default='relevance', type=str) start = (page - 1) * app.config['PAGE_LENGTH'] stop = start + app.config['PAGE_LENGTH'] titles = { 'archives': 'All Archives', 'decades': 'All Decades', 'organizations': 'All Organizations', 'people': 'All People', 'places': 'All Places', 'topics': 'All Topics' } assert b in titles.keys() assert sort in ('alpha', 'alpha-dsc', 'relevance', 'shuffle') collections = get_collections( *server_args + ('https://bmrc.lib.uchicago.edu/{}/'.format(b), )) browse_results = [] for k in collections.keys(): u = k.replace('https://bmrc.lib.uchicago.edu/', '').split('/')[1] s = '{} ({})'.format(unquote_plus(u), len(collections[k])) if not s.startswith('BMRC Portal'): browse_results.append((u, s, k)) total_pages = math.ceil(len(browse_results) / app.config['PAGE_LENGTH']) min_page_link, max_page_link = get_min_max_page_links(page, total_pages) if sort == 'alpha': browse_results.sort(key=lambda i: i[0].lower()) elif sort == 'alpha-dsc': browse_results.sort(key=lambda i: i[0].lower(), reverse=True) elif sort == 'relevance': browse_results.sort(key=lambda i: len(collections[i[2]]), reverse=True) elif sort == 'shuffle': random.shuffle(browse_results) return render_template('browse.html', b=b, breadcrumbs=[ ('https://bmrc.lib.uchicago.edu/', 'Black Metropolis Research Consortium'), ('/', 'Collections Portal') ], browse_results=browse_results[start:stop], max_page_link=max_page_link, min_page_link=min_page_link, page=page, page_length=app.config['PAGE_LENGTH'], search_results={}, sort=sort, start=start, title=titles[b], total_pages=total_pages)
def delete_all_finding_aids(): '''Delete all finding aids from the BMRC Portal MarkLogic database.''' collections = get_collections( *server_args + ('https://bmrc.lib.uchicago.edu/archives/', )) for collection, findingaids in collections.items(): for findingaid in findingaids: click.echo('DELETING {}...'.format(findingaid[0])) delete_findingaid(*server_args + (findingaid[0], ))
def homepage(): member_spotlight_title = '' member_spotlight_html = '' member_spotlight_img = '' for a in app.config['ARCHIVES']: if a['finding_aid_prefix'] == 'BMRC.NIU': member_spotlight_title = a['name'] member_spotlight_html = a['member_spotlight_html'] member_spotlight_img = a['archivebox_logo'] facet = random.choice(('https://bmrc.lib.uchicago.edu/topics/', 'https://bmrc.lib.uchicago.edu/people/', 'https://bmrc.lib.uchicago.edu/places/', 'https://bmrc.lib.uchicago.edu/organizations/', 'https://bmrc.lib.uchicago.edu/decades/')) discover_more_facet = facet.replace('https://bmrc.lib.uchicago.edu/', '').replace('/', '') collections = get_collections(*server_args + (facet, )) discover_more_uri = random.choice(list(collections.keys())) discover_more_title = unquote_plus(discover_more_uri).replace( 'https://bmrc.lib.uchicago.edu/', '').split('/')[1] return render_template('homepage.html', breadcrumbs=[ ('https://bmrc.lib.uchicago.edu/', 'Black Metropolis Research Consortium') ], discover_more_title=discover_more_title, discover_more_uri=discover_more_uri, discover_more_facet=discover_more_facet, member_spotlight_title=member_spotlight_title, member_spotlight_html=member_spotlight_html, member_spotlight_img=member_spotlight_img, search_results={}, title='Collections Portal')
def browse_people(): '''Browse all people in MarkLogic.''' click.echo( json.dumps( get_collections(*server_args + ('https://bmrc.lib.uchicago.edu/people/', ))))