Add opengraph metadata to photo details.

This commit is contained in:
Rasmus Kaj 2018-11-03 17:17:09 +01:00
parent 1b0e9bd698
commit de86a3432c
11 changed files with 16 additions and 10 deletions

View File

@ -6,6 +6,11 @@
@(req: &Request, lpath: &[Link], people: &[Person], places: &[Place], tags: &[Tag], position: &Option<Coord>, attribution: &Option<String>, camera: &Option<Camera>, photo: &Photo)
@:page_base(req, "Photo details", lpath, {
<meta property='og:title' content='Photo @if let Some(d) = photo.date {(@d.format("%F"))}'>
<meta property='og:type' content='image' />
<meta property='og:image' content='/img/@photo.id-m.jpg' />
<meta property='og:description' content='@for p in people{@p.person_name, }@for t in tags{#@t.tag_name, }@if let Some(p) = places.first() {@p.place_name}'>
}, {
<div class="details" data-imgid="@photo.id"@if let Some(g) = photo.grade { data-grade="@g"}@if let Some(ref p) = *position { data-position="[@p.x, @p.y]"}>
<div class="item"><img src="/img/@photo.id-m.jpg"@if let Some((w,h)) = photo.get_size(SizeTag::Medium.px()) { width="@w" height="@h"}></div>
<div class="meta">

View File

@ -5,7 +5,7 @@
@(req: &Request, title: &str, lpath: &[Link], photos: &[PhotoLink], coords: &[(Coord, i32)])
@:page_base(req, title, lpath, {
@:page_base(req, title, lpath, {}, {
<div class="group"@:data_positions(coords)>
@for p in photos {@:photo_link(p)}
</div>

View File

@ -3,7 +3,7 @@
@(req: &Request, next: Option<String>, message: Option<&str>)
@:page_base(req, "login", &[], {
@:page_base(req, "login", &[], {}, {
<form action="/login" method="post">
@if let Some(message) = message {<p>@message</p>}
<p><label for="user">User:</label>

View File

@ -4,7 +4,7 @@
@(req: &Request)
@:page_base(req, "Not found", &[], {
@:page_base(req, "Not found", &[], {}, {
<p>No page or photo match that url.</p>
@if req.authorized_user().is_none() {
<p>At least nothing publicly visible, you might try

View File

@ -4,7 +4,7 @@
@use templates::head;
@use templates::statics::{photos_css, admin_js, ux_js};
@(req: &Request, title: &str, lpath: &[Link], content: Content)
@(req: &Request, title: &str, lpath: &[Link], meta: Content, content: Content)
<!doctype html>
<html>
@ -19,6 +19,7 @@
}
<script src="/static/@ux_js.name" type="text/javascript" defer>
</script>
@:meta()
</head>
<body>
@:head(req, lpath)

View File

@ -3,7 +3,7 @@
@use templates::page_base;
@(req: &Request, people: &[Person])
@:page_base(req, "Photo people", &[], {
@:page_base(req, "Photo people", &[], {}, {
<ul class="allpeople">
@for p in people {
<li><a href="/person/@p.slug">@p.person_name</a>

View File

@ -4,7 +4,7 @@
@use templates::{data_positions, page_base, photo_link};
@(req: &Request, photos: &[PhotoLink], coords: &[(Coord, i32)], person: &Person)
@:page_base(req, &format!("Photos with {}", person.person_name), &[], {
@:page_base(req, &format!("Photos with {}", person.person_name), &[], {}, {
<div class="group"@:data_positions(coords)>
@for p in photos {@:photo_link(p)}
</div>

View File

@ -4,7 +4,7 @@
@use templates::{data_positions, page_base, photo_link};
@(req: &Request, photos: &[PhotoLink], coords: &[(Coord, i32)], place: &Place)
@:page_base(req, &format!("Photos from {}", place.place_name), &[], {
@:page_base(req, &format!("Photos from {}", place.place_name), &[], {}, {
<div class="group"@:data_positions(coords)>
@for p in photos {@:photo_link(p)}
</div>

View File

@ -4,7 +4,7 @@
@(req: &Request, places: &[Place])
@:page_base(req, "Photo places", &[], {
@:page_base(req, "Photo places", &[], {}, {
<ul class="allplaces">
@for p in places {
<li><a href="/place/@p.slug">@p.place_name</a>

View File

@ -5,7 +5,7 @@
@(req: &Request, photos: &[PhotoLink], coords: &[(Coord, i32)], tag: &Tag)
@:page_base(req, &format!("Photos tagged {}", tag.tag_name), &[], {
@:page_base(req, &format!("Photos tagged {}", tag.tag_name), &[], {}, {
<div class="group"@:data_positions(coords)>
@for p in photos {@:photo_link(p)}
</div>

View File

@ -3,7 +3,7 @@
@use templates::page_base;
@(req: &Request, tags: &[Tag])
@:page_base(req, "Photo tags", &[], {
@:page_base(req, "Photo tags", &[], {}, {
<ul class="alltags">
@for tag in tags {
<li><a href="/tag/@tag.slug">@tag.tag_name</a>