Skip to content

Commit

Permalink
Add opengraph
Browse files Browse the repository at this point in the history
Fix #151
  • Loading branch information
0x1eef committed Oct 5, 2023
1 parent 376bcbe commit fab1055
Show file tree
Hide file tree
Showing 123 changed files with 46 additions and 7 deletions.
2 changes: 2 additions & 0 deletions .bundle/config
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
BUNDLE_PATH: ".localgems"
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
build/
tmp/
node_modules/
.bundle/
.localgems/
*.log
.env
.idea
Expand Down
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -177,4 +177,4 @@ DEPENDENCIES
test-cmd.rb (~> 0.3)!

BUNDLED WITH
2.3.26
2.4.10
7 changes: 7 additions & 0 deletions nanoc/lib/helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,12 @@ def i18n
)
)
end

def erb(partial, local_assigns = {})
erb = File.binread File.join(Dir.getwd, "src", "html", "partials", partial)
scope = binding
local_assigns.each { scope.local_variable_set(_1, _2) }
ERB.new(erb).result(scope)
end
end
use_helper Helper
19 changes: 19 additions & 0 deletions nanoc/lib/mixins/opengraph.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
use_helper Module.new {
require_relative "helper"
include Helper

def opengraph(locale, basename, options = {})
erb "opengraph.html.erb", local_assigns(locale, basename, options)
end

def local_assigns(locale, basename, options)
case basename
when "stream.html.erb"
surah_id = options[:surah_id]
{ title: t(locale, "TheNobleQuran"),
description: t(locale, "meta.stream.description"),
url: "https://al-quran.reflectslight.io/#{locale}/#{surah_id}/",
image: "https://al-quran.reflectslight.io/images/opengraph/#{surah_id}.png" }
end
end
}
4 changes: 4 additions & 0 deletions nanoc/rules/assets.rules
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,7 @@ end
compile "/favicon.png" do
write(item.identifier.to_s)
end

compile "/images/opengraph/*.png" do
write(item.identifier.to_s)
end
5 changes: 3 additions & 2 deletions src/html/pages/surah/stream.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@
<html lang="<%= locale %>">
<head>
<title> <%= t(locale, "TheNobleQuran") %>: <%= surah_name %> </title>
<%= inline_css('/css/postman.css') %>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta charset="UTF-8">
<meta name="description" content="<%= t(locale, 'meta.stream.description', {surah_name:}) %>">
<meta name="description" content="<%= t(locale, 'meta.stream.description') %>">
<%= opengraph(locale, "stream.html.erb", {surah_id:}) %>
<link rel="icon" href="/favicon.png">
<%= inline_css('/css/postman.css') %>
</head>
<body>
<div class="postman loader">
Expand Down
6 changes: 6 additions & 0 deletions src/html/partials/opengraph.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<meta property="og:type" content="website"/>
<meta property="og:title" content="<%= title %>"/>
<meta property="og:description" content="<%= description %>"/>
<meta property="og:url" content="<%= url %>"/>
<meta property="og:image" content="<%= image %>"
<meta property="og:image:type" content="image/png"/>
6 changes: 3 additions & 3 deletions src/i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"comma": ",",
"meta": {
"index": {"description": "Read and listen to The Noble Quran."},
"stream": {"description": "Read and listen to '%{surah_name}' from The Noble Quran."}
"stream": {"description": "Read and listen to The Noble Quran."}
},
"surahs": {
"names": [
Expand Down Expand Up @@ -135,8 +135,8 @@
"ayah": "آية",
"comma": "،",
"meta": {
"index": {"description": "اقرأ واستمع إلى القرآن الكريم."},
"stream": {"description": "اقرأ واستمع إلى القرآن الكريم - '%{surah_name}'."}
"index": {"description": "اقرأ واستمع إلى القرآن الكريم"},
"stream": {"description": "اقرأ واستمع إلى القرآن الكريم"}
},
"surahs": {
"names": [
Expand Down
Binary file added src/images/opengraph/1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/images/opengraph/10.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/images/opengraph/100.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/images/opengraph/101.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/images/opengraph/102.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/images/opengraph/103.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/images/opengraph/104.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/images/opengraph/105.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/images/opengraph/106.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/images/opengraph/107.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/images/opengraph/108.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/images/opengraph/109.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/images/opengraph/11.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/images/opengraph/110.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/images/opengraph/111.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/images/opengraph/112.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/images/opengraph/113.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/images/opengraph/114.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/images/opengraph/12.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/images/opengraph/13.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/images/opengraph/14.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/images/opengraph/15.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/images/opengraph/16.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/images/opengraph/17.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/images/opengraph/18.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/images/opengraph/19.png
Binary file added src/images/opengraph/2.png
Binary file added src/images/opengraph/20.png
Binary file added src/images/opengraph/21.png
Binary file added src/images/opengraph/22.png
Binary file added src/images/opengraph/23.png
Binary file added src/images/opengraph/24.png
Binary file added src/images/opengraph/25.png
Binary file added src/images/opengraph/26.png
Binary file added src/images/opengraph/27.png
Binary file added src/images/opengraph/28.png
Binary file added src/images/opengraph/29.png
Binary file added src/images/opengraph/3.png
Binary file added src/images/opengraph/30.png
Binary file added src/images/opengraph/31.png
Binary file added src/images/opengraph/32.png
Binary file added src/images/opengraph/33.png
Binary file added src/images/opengraph/34.png
Binary file added src/images/opengraph/35.png
Binary file added src/images/opengraph/36.png
Binary file added src/images/opengraph/37.png
Binary file added src/images/opengraph/38.png
Binary file added src/images/opengraph/39.png
Binary file added src/images/opengraph/4.png
Binary file added src/images/opengraph/40.png
Binary file added src/images/opengraph/41.png
Binary file added src/images/opengraph/42.png
Binary file added src/images/opengraph/43.png
Binary file added src/images/opengraph/44.png
Binary file added src/images/opengraph/45.png
Binary file added src/images/opengraph/46.png
Binary file added src/images/opengraph/47.png
Binary file added src/images/opengraph/48.png
Binary file added src/images/opengraph/49.png
Binary file added src/images/opengraph/5.png
Binary file added src/images/opengraph/50.png
Binary file added src/images/opengraph/51.png
Binary file added src/images/opengraph/52.png
Binary file added src/images/opengraph/53.png
Binary file added src/images/opengraph/54.png
Binary file added src/images/opengraph/55.png
Binary file added src/images/opengraph/56.png
Binary file added src/images/opengraph/57.png
Binary file added src/images/opengraph/58.png
Binary file added src/images/opengraph/59.png
Binary file added src/images/opengraph/6.png
Binary file added src/images/opengraph/60.png
Binary file added src/images/opengraph/61.png
Binary file added src/images/opengraph/62.png
Binary file added src/images/opengraph/63.png
Binary file added src/images/opengraph/64.png
Binary file added src/images/opengraph/65.png
Binary file added src/images/opengraph/66.png
Binary file added src/images/opengraph/67.png
Binary file added src/images/opengraph/68.png
Binary file added src/images/opengraph/69.png
Binary file added src/images/opengraph/7.png
Binary file added src/images/opengraph/70.png
Binary file added src/images/opengraph/71.png
Binary file added src/images/opengraph/72.png
Binary file added src/images/opengraph/73.png
Binary file added src/images/opengraph/74.png
Binary file added src/images/opengraph/75.png
Binary file added src/images/opengraph/76.png
Binary file added src/images/opengraph/77.png
Binary file added src/images/opengraph/78.png
Binary file added src/images/opengraph/79.png
Binary file added src/images/opengraph/8.png
Binary file added src/images/opengraph/80.png
Binary file added src/images/opengraph/81.png
Binary file added src/images/opengraph/82.png
Binary file added src/images/opengraph/83.png
Binary file added src/images/opengraph/84.png
Binary file added src/images/opengraph/85.png
Binary file added src/images/opengraph/86.png
Binary file added src/images/opengraph/87.png
Binary file added src/images/opengraph/88.png
Binary file added src/images/opengraph/89.png
Binary file added src/images/opengraph/9.png
Binary file added src/images/opengraph/90.png
Binary file added src/images/opengraph/91.png
Binary file added src/images/opengraph/92.png
Binary file added src/images/opengraph/93.png
Binary file added src/images/opengraph/94.png
Binary file added src/images/opengraph/95.png
Binary file added src/images/opengraph/96.png
Binary file added src/images/opengraph/97.png
Binary file added src/images/opengraph/98.png
Binary file added src/images/opengraph/99.png

0 comments on commit fab1055

Please sign in to comment.