Browse Source

feat(metadata): Allow silo data to be optional.

jackyalcine 1 month ago
parent
commit
b18d361b1a
Signed by: Jacky Alciné <yo@jacky.wtf> GPG Key ID: 537A4F904B15268D

+ 7
- 5
lib/repo.ex View File

@@ -72,12 +72,14 @@ defmodule Koype.Repo do
72 72
     Koype.host() <> get_path_for_record(record, router_method)
73 73
   end
74 74
 
75
-  def get_path_for_record(%{slug: slug}, router_method) when is_binary(slug) do
76
-    router_method.(Koype.Web.Endpoint, :show, slug)
77
-  end
75
+  def get_path_for_record(record, router_method) do
76
+    case record do
77
+      %{slug: slug} when is_binary(slug) ->
78
+        router_method.(Koype.Web.Endpoint, :show, slug)
78 79
 
79
-  def get_path_for_record(%{id: id}, router_method) do
80
-    router_method.(Koype.Web.Endpoint, :show, id)
80
+      %{id: id} ->
81
+        router_method.(Koype.Web.Endpoint, :show, id)
82
+    end
81 83
   end
82 84
 
83 85
   def resolve_token_from_uri(url, token)

+ 42
- 42
priv/themes/default/tmpl/entry/view/comments.html.liquid View File

@@ -1,47 +1,47 @@
1 1
 {% assign comment_count = webmention.of.reply|size %}
2 2
 {% if comment_count == 0 %}
3
-<figure class="order-1 order-2-l w-100 {% if entry.interaction_count == 0 %}w-auto-l {%endif %}dn db-l">
4
-  <img src="{% asset_path dist/images/flamenco/flamenco-no-comments.png %}"
5
-        class="w-auto h4 order-1 mb2 db center"
6
-        alt="Image of person on planet in a suit talking to themselves" />
7
-  <figcaption class="tc f6 gray">
8
-    There's <em>no responses</em> for this {{ entry.type }} yet.
9
-  </figcaption>
10
-</figure>
3
+  <figure class="order-1 order-2-l w-100 {% if entry.interaction_count == 0 %}w-auto-l {%endif %}dn db-l">
4
+    <img src="{% asset_path dist/images/flamenco/flamenco-no-comments.png %}"
5
+         class="w-auto h4 order-1 mb2 db center"
6
+         alt="Image of person on planet in a suit talking to themselves" />
7
+    <figcaption class="tc f6 gray">
8
+      There's <em>no responses</em> for this {{ entry.type }} yet.
9
+    </figcaption>
10
+  </figure>
11 11
 {% else %}
12
-  <details open class="order-3 flex-auto flex-grow mt3">
13
-  <summary class="lh-copy f5 db pl1 pointer tc">
14
-    <i class="w1 h1 v-mid" data-feather="more-horizontal"></i>
15
-    <span class="v-mid">
16
-      View <strong>{{ comment_count }}</strong> {{ "reply"|inflect:comment_count }}
17
-    </span>
18
-  </summary>
19
-  <ol class="list ph2 w-100">
20
-    {% for comment in webmention.of.reply %}
21
-      <li id="{{ comment.id }}" class="lh-copy p-comment h-cite flex flex-row">
22
-        <a href="{{ comment.author.url }}" class="u-author h-card link">
23
-          {% if comment.author.photo %}
24
-          <img src="{{ comment.author.photo }}"
25
-               title="{{ comment.author.name }}"
26
-               alt="{{ comment.author.name }}"
27
-               class="u-photo db center w-auto v-mid mw3 br2 pa2" />
28
-          {% endif %}
29
-          <strong class="db mw4 lh-copy f6 truncate center tc p-name">{{ comment.author.name }}</strong>
30
-        </a>
31
-        <div class="flex-auto flex-grow ph2 self-end">
32
-          {% if comment.source.title != comment.source.content.text %}<h3 class="f4 v-mid lh-title mt0 p-name">{{ comment.source.title }}</h3>{% endif %}
33
-          <aside class="bg-blue pa2 gray v-mid f5 measure e-content mv0 self-end flex-auto flex-grow ml2 db" data-post-type="{{ entry.type }}">
34
-            {{ comment.source.content.html }}
35
-          </aside>
36
-          <a href="{{ comment.url }}"  class="u-url link no-underline f7 gray">
37
-            {% if comment.source.published != empty %}<i class="h1 w1 pa1 v-mid" data-feather="clock">posted</i>
38
-            <time datetime="{{ comment.source.published }}" class="dt-published underline">{{ comment.source.published }}</time>&nbsp;&bull;&nbsp;{% endif %}
39
-            received
40
-            <time datetime="{{ comment.accessed }}" class="dt-accessed underline">{{ comment.accessed }}</time>
12
+  <details open class="order-3 flex-auto flex-grow mt3 w-100">
13
+    <summary class="lh-copy f5 db pl1 pointer tc">
14
+      <i class="w1 h1 v-mid" data-feather="more-horizontal"></i>
15
+      <span class="v-mid">
16
+        View <strong>{{ comment_count }}</strong> {{ "reply"|inflect:comment_count }}
17
+      </span>
18
+    </summary>
19
+    <ol class="list ph2 w-100">
20
+      {% for comment in webmention.of.reply %}
21
+        <li id="{{ comment.id }}" class="lh-copy p-comment h-cite flex flex-row">
22
+          <a href="{{ comment.author.url }}" class="u-author h-card link">
23
+            {% if comment.author.photo %}
24
+              <img src="{{ comment.author.photo }}"
25
+                   title="{{ comment.author.name }}"
26
+                   alt="{{ comment.author.name }}"
27
+                   class="u-photo db center w-auto v-mid mw3 br2 pa2" />
28
+            {% endif %}
29
+            <strong class="db mw4 lh-copy f6 truncate center tc p-name">{{ comment.author.name }}</strong>
41 30
           </a>
42
-        </div>
43
-      </li>
44
-    {% endfor %}
45
-  </ol>
46
-</details>
31
+          <div class="flex-auto flex-grow ph2 self-end">
32
+            {% if comment.source.title != comment.source.content.text %}<h3 class="f4 v-mid lh-title mt0 p-name">{{ comment.source.title }}</h3>{% endif %}
33
+            <aside class="bg-blue pa2 gray v-mid f5 measure e-content mv0 self-end flex-auto flex-grow ml2 db" data-post-type="{{ entry.type }}">
34
+              {{ comment.source.content.html }}
35
+            </aside>
36
+            <a href="{{ comment.url }}"  class="u-url link no-underline f7 gray">
37
+              {% if comment.source.published != empty %}<i class="h1 w1 pa1 v-mid" data-feather="clock">posted</i>
38
+                <time datetime="{{ comment.source.published }}" class="dt-published underline">{{ comment.source.published }}</time>&nbsp;&bull;&nbsp;{% endif %}
39
+              received
40
+              <time datetime="{{ comment.accessed }}" class="dt-accessed underline">{{ comment.accessed }}</time>
41
+            </a>
42
+          </div>
43
+        </li>
44
+      {% endfor %}
45
+    </ol>
46
+  </details>
47 47
 {% endif %}

+ 3
- 3
web/router.ex View File

@@ -115,17 +115,17 @@ defmodule Koype.Web.Router do
115 115
 
116 116
     resources("/contacts", ContactController)
117 117
 
118
-    resources("/webmentions", WebmentionController, only: [:show, :index, :delete])
119 118
     post("/webmentions/:id", WebmentionController, :refresh)
120 119
     put("/webmentions/moderate/:id", WebmentionController, :moderate)
120
+    resources("/webmentions", WebmentionController, only: [:show, :index, :delete])
121 121
 
122 122
     post("/themes/custom", ThemeController, :apply_custom)
123 123
     put("/themes/import", ThemeController, :import)
124
-    resources("/themes", ThemeController, except: ~w(edit create)a)
125 124
     post("/themes/:id/apply", ThemeController, :apply)
125
+    resources("/themes", ThemeController, except: ~w(edit create)a)
126 126
 
127
-    resources("/domain-rule-sets", DomainRuleSetController, except: ~w(new)a)
128 127
     post("/domain-rule-sets/global", DomainRuleSetController, :global_status)
128
+    resources("/domain-rule-sets", DomainRuleSetController, except: ~w(new)a)
129 129
   end
130 130
 
131 131
   scope "/indie", Koype.Web, as: :indie do

+ 23
- 0
web/templates/settings/_view-metadata.html.eex View File

@@ -0,0 +1,23 @@
1
+<input type="hidden" name="_csrf_token" value="<%= Phoenix.Controller.get_csrf_token %>" />
2
+<fieldset class="b--moon-gray bw1 ba measure">
3
+  <legend class="pa2">Silo Information Exposure</legend>
4
+  <p class="lh-copy measure-wide">Pick which <a class="link" href="https://indieweb.org/silo">silos</a> you'd want to inject <em>extra code on your site</em> for.</p>
5
+  <dl>
6
+    <dt class="lh-copy pv2">
7
+    <div class="pretty p-success p-fill p-switch center">
8
+      <input type="checkbox" name="silo[]" value="facebook" <%= if Koype.Setting.get("metadata:facebook", false), do: "checked" %> />
9
+      <div class="state">
10
+        <label>Facebook</label>
11
+      </div>
12
+    </div>
13
+    </dt>
14
+    <dt class="lh-copy pv2">
15
+    <div class="pretty p-success p-fill p-switch center">
16
+      <input type="checkbox" name="silo[]" value="twitter" <%= if Koype.Setting.get("metadata:twitter", false), do: "checked" %> />
17
+      <div class="state">
18
+        <label>Twitter</label>
19
+      </div>
20
+    </div>
21
+    </dt>
22
+  </dl>
23
+</fieldset>

+ 1
- 3
web/templates/settings/_view-relme.html.eex View File

@@ -9,7 +9,7 @@
9 9
     <input type="url" autocomplete="url" name="uri" placeholder="A profile link elsewhere." aria-describedby="uri-des" />
10 10
   </div>
11 11
 </fieldset>
12
-<% 
12
+<%
13 13
   links = Koype.Repo.RelMe |> Koype.Repo.descending(:inserted_at) |> Koype.Repo.paginate(@conn.params)
14 14
   total_link_count = links.total_entries
15 15
   link_count = length(links.entries)
@@ -82,5 +82,3 @@
82 82
   </div>
83 83
 </article>
84 84
 <% end %>
85
-
86
-

+ 2
- 0
web/templates/settings/view.html.eex View File

@@ -18,6 +18,8 @@
18 18
     <a class="navy fw5 link" href="<%= settings_path(@conn, :view, component: :totp) %>">Sign In Code</a>
19 19
     <span class="v-mid">&bull;</span>
20 20
     <a class="navy fw5 link" href="<%= settings_path(@conn, :view, component: :url_parsing) %>">URI Parsing</a>
21
+    <span class="v-mid">&bull;</span>
22
+    <a class="navy fw5 link" href="<%= settings_path(@conn, :view, component: :metadata) %>">Metadata</a>
21 23
   </nav>
22 24
   <form enctype="multipart/form-data" action="<%= settings_path(@conn, :apply) %>" method="post" class="mv2">
23 25
     <input type=hidden name=_csrf_token value="<%= Phoenix.Controller.get_csrf_token %>" />

+ 5
- 2
web/views/entry_view.ex View File

@@ -145,8 +145,11 @@ defmodule Koype.Web.EntryView do
145 145
     %{name: :author, content: Koype.host()}
146 146
   end
147 147
 
148
-  def tags(:meta, "entry/view", _assigns),
149
-    do: ~w(description generator itemprop)a ++ @opengraph_props ++ @twitter_props
148
+  def tags(:meta, "entry/view", _assigns) do
149
+    ~w(description generator itemprop)a
150
+    |> Enum.concat(if Koype.Setting.get("metadata:facebook", false), do: @opengraph_props, else: [])
151
+    |> Enum.concat(if Koype.Setting.get("metadata:twitter", false), do: @twitter_props, else: [])
152
+  end
150 153
 
151 154
   def tags(:meta, "entry/gone", _assigns), do: ~w(author)a
152 155
   def tags(:meta, "entry/not-found", _assigns), do: ~w()a

Loading…
Cancel
Save