Skip to content

Commit

Permalink
Merge pull request #270 from piwheels/264-twitter-cards
Browse files Browse the repository at this point in the history
Add Twitter card meta tags
  • Loading branch information
bennuttall committed Jul 16, 2021
2 parents d08872c + fec3aef commit edf6a2d
Show file tree
Hide file tree
Showing 10 changed files with 24 additions and 11 deletions.
Binary file added piwheels/master/static/piwheels-logo-large.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 0 additions & 1 deletion piwheels/master/templates/404.pt
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<div metal:use-macro="layout">
<div metal:fill-slot="title" tal:omit-tag="1">404 - file not found</div>
<div metal:fill-slot="content">
<div class="row">
<div class="small-12 columns">
Expand Down
1 change: 0 additions & 1 deletion piwheels/master/templates/faq.pt
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<div metal:use-macro="layout">
<div metal:fill-slot="title" tal:omit-tag="1">FAQ</div>
<div metal:fill-slot="content">
<div class="row">
<div class="small-12 columns">
Expand Down
1 change: 0 additions & 1 deletion piwheels/master/templates/index.pt
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<div metal:use-macro="layout">
<div metal:fill-slot="title" tal:omit-tag="1">Home</div>
<div metal:fill-slot="scripts" tal:omit-tag="1">
<script src="/blogposts.js"></script>
</div>
Expand Down
1 change: 0 additions & 1 deletion piwheels/master/templates/json.pt
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<div metal:use-macro="layout">
<div metal:fill-slot="title" tal:omit-tag="1">JSON API</div>
<div metal:fill-slot="content">
<div class="row">
<div class="small-12 medium-8 columns">
Expand Down
9 changes: 8 additions & 1 deletion piwheels/master/templates/layout.pt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<meta charset="utf-8" />
<meta http-equiv="x-ua-compatible" content="ie=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>piwheels - <span metal:define-slot="title" /></title>
<title>piwheels - ${title}</title>
<link rel="stylesheet" href="/foundation-float.min.css">
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto">
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto+Condensed">
Expand All @@ -13,6 +13,13 @@
<link rel="shortcut icon" href="/favicon.ico" type="image/x-icon">
<link rel="icon" href="/favicon.ico" type="image/x-icon">
<link tal:condition="page == 'project'" href="https://www.piwheels.org/project/${project}/" rel="canonical">
<!-- TWITTER CARD -->
<meta name="twitter:card" content="summary" />
<meta name="twitter:site" content="@piwheels" />
<meta name="twitter:title" content="piwheels - ${title}" />
<meta name="twitter:description" content="${description}" />
<meta name="twitter:image" content="https://www.piwheels.org/piwheels-logo-large.png" />
<!-- END TWITTER CARD -->
</head>
<body>
<header>
Expand Down
1 change: 0 additions & 1 deletion piwheels/master/templates/packages.pt
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<div metal:use-macro="layout">
<div metal:fill-slot="title" tal:omit-tag="1">Package List</div>
<div metal:fill-slot="scripts" tal:omit-tag="1">
<script src="/packages.js"></script>
</div>
Expand Down
1 change: 0 additions & 1 deletion piwheels/master/templates/project.pt
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<div metal:use-macro="layout">
<div metal:fill-slot="title" tal:omit-tag="1">${project}</div>
<div metal:fill-slot="scripts" tal:omit-tag="1">
<script src="/project.js"></script>
</div>
Expand Down
1 change: 0 additions & 1 deletion piwheels/master/templates/stats.pt
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<div metal:use-macro="layout">
<div metal:fill-slot="title" tal:omit-tag="1">Stats</div>
<div metal:fill-slot="content">
<div class="row">
<div class="small-12 medium-8 columns">
Expand Down
19 changes: 16 additions & 3 deletions piwheels/master/the_scribe.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,12 +155,21 @@ def setup_output_path(self):
source = pkg_resources.resource_stream(__name__, 'static/' + filename)
with AtomicReplaceFile(self.output_path / filename) as f:
shutil.copyfileobj(source, f)
startup_templates = {'faq.pt', 'packages.pt', 'stats.pt', 'json.pt', '404.pt'}
startup_templates = {
'faq.pt': ('FAQ', 'frequently asked questions about the piwheels project'),
'packages.pt': ('Package search', 'search for packages in the piwheels repository'),
'stats.pt': ('Stats', 'piwheels usage statistics'),
'json.pt': ('JSON API', 'information about the piwheels JSON API'),
'404.pt': ('404 - file not found', 'file not found'),
}
for filename in pkg_resources.resource_listdir(__name__, 'templates'):
if filename in startup_templates:
title, description = startup_templates[filename]
source = self.templates[filename](
layout=self.templates['layout']['layout'],
page=filename.replace('.pt', '')
page=filename.replace('.pt', ''),
title=title,
description=description,
)
with AtomicReplaceFile(
(self.output_path / filename).with_suffix('.html'),
Expand Down Expand Up @@ -232,7 +241,10 @@ def write_homepage(self, statistics):
layout=self.templates['layout']['layout'],
timestamp=dt.strftime('%Y-%m-%d %H:%M %Z'),
page='home',
stats=statistics))
title='Home',
description='Python package repository providing wheels for Raspberry Pi',
stats=statistics,
))

def write_search_index(self, search_index):
"""
Expand Down Expand Up @@ -385,6 +397,7 @@ def write_project_page(self, package, releases, description):
dependencies=dependencies,
format_size=format_size,
timestamp=dt.strftime('%Y-%m-%d %H:%M %Z'),
title=project_name,
description=description,
page='project'))
project_aliases = self.db.get_package_aliases(package)
Expand Down

0 comments on commit edf6a2d

Please sign in to comment.