Add a sitemap.txt for popular public repos

and reference it from the robots.txt
This commit is contained in:
Jake Moshenko 2016-06-17 13:52:27 -04:00
parent c712be05e2
commit a1cf12e460
11 changed files with 146 additions and 52 deletions

View file

@ -2,15 +2,17 @@ import json
import logging
from urlparse import urlparse
from datetime import timedelta
from cachetools import lru_cache
from flask import (abort, redirect, request, url_for, make_response, Response,
from flask import (abort, redirect, request, url_for, make_response, Response, render_template,
Blueprint, send_from_directory, jsonify, send_file)
from flask.ext.login import current_user
import features
from app import app, billing as stripe, build_logs, avatar, signer, log_archive, config_provider
from app import (app, billing as stripe, build_logs, avatar, signer, log_archive, config_provider,
get_app_url)
from auth import scopes
from auth.auth import require_session_login, process_oauth, has_basic_auth, process_auth_or_cookie
from auth.permissions import (AdministerOrganizationPermission, ReadRepositoryPermission,
@ -282,9 +284,19 @@ def disclaimer():
@web.route('/robots.txt', methods=['GET'])
@no_cache
def robots():
return send_from_directory('static', 'robots.txt')
robots_txt = make_response(render_template('robots.txt', baseurl=get_app_url()))
robots_txt.headers['Content-Type'] = 'text/plain'
return robots_txt
@web.route('/sitemap.xml', methods=['GET'])
def sitemap():
popular_repo_tuples = model.repository.list_popular_public_repos(50, timedelta(weeks=1))
xml = make_response(render_template('sitemap.xml', public_repos=popular_repo_tuples,
baseurl=get_app_url()))
xml.headers['Content-Type'] = 'application/xml'
return xml
@web.route('/buildlogs/<build_uuid>', methods=['GET'])