Debian Codegraph @

tpl/tplimpl/embedded/templates/_shortcodes/x_simple.html

raw
1 {{- if not site.Config.Privacy.X.Disable -}}
2 {{- $id := or (.Get "id") "" -}}
3 {{- $user := or (.Get "user") "" -}}
4 {{- if and $id $user -}}
5 {{- template "render-simple-x" (dict "id" $id "user" $user "ctx" .) -}}
6 {{- else -}}
7 {{- errorf "The %q shortcode requires two named parameters: user and id. See %s" .Name .Position -}}
8 {{- end -}}
9 {{- end -}}
10
11 {{- define "render-simple-x" -}}
12 {{- $dnt := site.Config.Privacy.X.EnableDNT }}
13 {{- $url := printf "https://x.com/%v/status/%v" .user .id -}}
14 {{- $query := querify "url" $url "dnt" $dnt "omit_script" true -}}
15 {{- $request := printf "https://publish.x.com/oembed?%s" $query -}}
16 {{- with try (resources.GetRemote $request) -}}
17 {{- with .Err -}}
18 {{- warnidf "shortcode-x-simple-getremote" "The %q shortcode was unable to retrieve the remote data: %s. See %s" $.ctx.Name . $.ctx.Position -}}
19 {{- else with .Value -}}
20 {{- if not site.Config.Services.X.DisableInlineCSS }}
21 {{- template "__h_simple_x_css" (dict "ctx" $.ctx) }}
22 {{- end }}
23 {{- (. | transform.Unmarshal).html | safeHTML -}}
24 {{- else -}}
25 {{- warnidf "shortcode-x-simple-getremote" "The %q shortcode was unable to retrieve the remote data. See %s" $.ctx.Name $.ctx.Position -}}
26 {{- end -}}
27 {{- end -}}
28 {{- end -}}
29
30 {{- define "__h_simple_x_css" -}}
31 {{- if not (.ctx.Page.Store.Get "__h_simple_x_css") -}}
32 {{/* Only include once */}}
33 {{- .ctx.Page.Store.Set "__h_simple_x_css" true -}}
34 <style type="text/css">
35 .twitter-tweet {
36 font:
37 14px/1.45 -apple-system,
38 BlinkMacSystemFont,
39 "Segoe UI",
40 Roboto,
41 Oxygen-Sans,
42 Ubuntu,
43 Cantarell,
44 "Helvetica Neue",
45 sans-serif;
46 border-left: 4px solid #2b7bb9;
47 padding-left: 1.5em;
48 color: #555;
49 }
50 .twitter-tweet a {
51 color: #2b7bb9;
52 text-decoration: none;
53 }
54 blockquote.twitter-tweet a:hover,
55 blockquote.twitter-tweet a:focus {
56 text-decoration: underline;
57 }
58 </style>
59 {{- end -}}
60 {{- end -}}