Skip to content

Commit

Permalink
Switch to alternate method (HTML tag) of Google site verification
Browse files Browse the repository at this point in the history
This is cleaner than the default method (HTML file upload).
  • Loading branch information
grosskur committed Feb 22, 2014
1 parent 4a86c2b commit 0f66ae1
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 33 deletions.
12 changes: 3 additions & 9 deletions ec2price/app.py
Expand Up @@ -10,7 +10,7 @@
import tornado.web
import webassets.loaders

from .web import MainHandler, HealthCheckHandler, GoogleVerificationHandler
from .web import MainHandler, HealthCheckHandler
from .collector import collect
from .model import Model

Expand Down Expand Up @@ -69,7 +69,7 @@ def main(args):
gauges_site_id = os.getenv('GAUGES_SITE_ID')
ga_tracking_id = os.getenv('GA_TRACKING_ID')
ga_domain = os.getenv('GA_DOMAIN')
google_verification_id = os.getenv('GOOGLE_VERIFICATION_ID')
google_site_verification_id = os.getenv('GOOGLE_SITE_VERIFICATION_ID')

if not table_prefix:
parser.error('TABLE_PREFIX is required')
Expand All @@ -86,18 +86,12 @@ def main(args):
'gauges_site_id': gauges_site_id,
'ga_tracking_id': ga_tracking_id,
'ga_domain': ga_domain,
'google_verification_id': google_verification_id,
'google_site_verification_id': google_site_verification_id,
}
handlers = [
(r'/', MainHandler, params),
(r'/healthcheck', HealthCheckHandler, params),
]
if google_verification_id:
handlers += [
(r'/google{}.html'.format(google_verification_id),
GoogleVerificationHandler, params),
]

_start_tornado_app(debug, cookie_secret, port, address, handlers)
elif opts.cmd == 'collector':
table_prefix = os.getenv('TABLE_PREFIX')
Expand Down
9 changes: 7 additions & 2 deletions ec2price/templates/base.html
@@ -1,8 +1,13 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="description" content="EC2 spot price graphs">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<meta name="title" content="EC2 spot price graphs">
<meta name="description" content="Price graphs for Amazon EC2 spot instances.">
<meta name="keywords" content="ec2 spot pricing, ec2 spot prices, ec2 prices, ec2 spot instance, spot price graphs, spot instance pricing">
{% if google_site_verification_id %}
<meta name="google-site-verification" content="{{ google_site_verification_id }}">
{% end %}
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>EC2 spot price graphs</title>
<link rel="shortcut icon" href="{{ static_url("favicon.ico") }}">
Expand Down
41 changes: 19 additions & 22 deletions ec2price/web.py
Expand Up @@ -15,19 +15,13 @@

class BaseHandler(tornado.web.RequestHandler):
def initialize(self, model, asset_env, gauges_site_id, ga_tracking_id,
ga_domain, google_verification_id):
ga_domain, google_site_verification_id):
self._model = model
self._asset_env = asset_env
self._gauges_site_id = gauges_site_id
self._ga_tracking_id = ga_tracking_id
self._ga_domain = ga_domain
self._google_verification_id = google_verification_id


class GoogleVerificationHandler(BaseHandler):
def get(self):
self.write('google-site-verification: google{}.html'.format(
self._google_verification_id))
self._google_site_verification_id = google_site_verification_id


class HealthCheckHandler(BaseHandler):
Expand Down Expand Up @@ -84,17 +78,20 @@ def get(self):

windows = [1, 3, 8, 15, 30, 60]

self.render('main.html',
asset_env=self._asset_env,
gauges_site_id=self._gauges_site_id,
ga_tracking_id=self._ga_tracking_id,
ga_domain=self._ga_domain,
data=data,
product_description=product_description,
product_descriptions=product_descriptions,
instance_type=instance_type,
instance_types=instance_types,
region=region,
regions=regions,
window=window,
windows=windows)
self.render(
'main.html',
asset_env=self._asset_env,
gauges_site_id=self._gauges_site_id,
ga_tracking_id=self._ga_tracking_id,
ga_domain=self._ga_domain,
google_site_verification_id=self._google_site_verification_id,
data=data,
product_description=product_description,
product_descriptions=product_descriptions,
instance_type=instance_type,
instance_types=instance_types,
region=region,
regions=regions,
window=window,
windows=windows,
)

0 comments on commit 0f66ae1

Please sign in to comment.