def show_large_map(key): kwargs = get_template_hash() if re.search('^\d+$', key): kwargs['map'] = Map.all().filter("id =", int(key)).get() elif re.search('^(\d+,)*\d+$', key): kwargs['map_id_list'] = ",".join(str(x) for x in key.split(',')) else: map = Map.all().filter("tag =", key).fetch(1000) kwargs['map_id_list'] = ",".join(str(x.id) for x in map) return render_template('show_large_map.html', **kwargs)
def xml(map_id): if re.search('^\d+$', map_id): maps = Map.all().filter("id = ", int(map_id)).fetch(1) else: map_id_list = [int(x) for x in map_id.split(',')] maps = Map.all().filter("id IN", map_id_list).fetch(1000) for map in maps: map.polylines = Polyline.all().filter("map =", map).fetch(1000) map.markers = Marker.all().filter("map =", map).fetch(1000) xml = render_template('map.xml', maps=maps) resp = app.make_response(xml) resp.headers['Content-Type'] = 'application/xml; charset=UTF-8' return resp
def list_tags(): kwargs = get_template_hash() kwargs['tags'] = {} for map in Map.all().fetch(1000): for tag in map.tag: if tag not in kwargs['tags']: kwargs['tags'][tag] = 0 kwargs['tags'][tag] += 1 return render_template('list_tags.html', **kwargs)
def index(): page = int(request.args.get('page', 0)) kwargs = get_template_hash() maps = Map.all().order('-id').fetch(PAGESIZE + 1, page * PAGESIZE) kwargs['page'] = page if len(maps) == PAGESIZE + 1: kwargs['maps'] = maps[:PAGESIZE] kwargs['nextpage'] = True else: kwargs['maps'] = maps kwargs['nextpage'] = False return render_template('list.html', **kwargs)
def list(tag=None): mode = request.args.get('mode') page = int(request.args.get('page', 0)) kwargs = get_template_hash() query = Map.all().order('-id') if tag: query = query.filter("tag =", tag) maps = query.fetch(PAGESIZE + 1, page * PAGESIZE) kwargs['page'] = page if len(maps) == PAGESIZE + 1: kwargs['maps'] = maps[:PAGESIZE] kwargs['nextpage'] = True else: kwargs['maps'] = maps kwargs['nextpage'] = False return render_template('list.html', **kwargs)
def show_map(map_id): kwargs = get_template_hash() kwargs['map'] = Map.all().filter("id =", map_id).get() return render_template('show_map.html', **kwargs)
def sitemap(): maps = Map.all().order('-id').fetch(1000) return render_template('sitemap.xml', maps=maps)