Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open graph tags #95

Merged
merged 2 commits into from
Jun 16, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion pskb_website/models/article.py
Original file line number Diff line number Diff line change
Expand Up @@ -993,7 +993,7 @@ def stack_image_url(self):
static_path = os.path.join(app.static_folder, file_path)

if os.path.isfile(static_path):
return url_for('static', filename=file_path)
return url_for('static', filename=file_path, _external=True)

return None

Expand Down
14 changes: 11 additions & 3 deletions pskb_website/templates/article.html
Original file line number Diff line number Diff line change
@@ -1,12 +1,20 @@
{% extends "layout.html" %}

{% block metatags %}
{% block open_graph %}
{{ super() }}

<!-- FB share/like are really bad at picking up the right info without these -->
<meta property="og:type" content="article" />
<meta property="og:title" content="{{article.title}}" />
<meta property="og:site_name" content="hack.guides()" />
<meta property="og:url" content="{{canonical_url}}" />
{{ super() }}
<meta property="og:description" content="Guide related to {{article.stacks[0]}}" />

{% if article.stack_image_url and article.stack_image_url.endswith(('.png', '.jpg', '.jpeg')) %}
<meta property="og:image" content="{{article.stack_image_url}}" />
<meta property="og:image:width" content="400" />
<meta property="og:image:height" content="400" />
{% endif %}

{% endblock %}


Expand Down
12 changes: 12 additions & 0 deletions pskb_website/templates/layout.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,18 @@
<meta name="viewport" content="width=device-width, initial-scale=1">
{% endblock %}

{% block open_graph %}
<meta property="og:site_name" content="hack.guides()" />
{% if not article %}
<meta property="og:title" content="hack.guides()" />
<meta property="og:url" content="{{request.url}}" />
<meta property="og:description" content="A developer community for writing guides" />
<meta property="og:image" content="{{url_for('static', filename='img/logos/hackguides-black-470x80.png', _external=True)}}" />
<meta property="og:image:width" content="199" />
<meta property="og:image:height" content="43" />
{% endif %}
{% endblock %}

{% block title %}

<title>hack.guides()</title>
Expand Down