2018-05-30 16:42:32 -04:00
|
|
|
{{- $pc := .Page.Site.Config.Privacy.Twitter -}}
|
|
|
|
{{- $sc := .Page.Site.Config.Services.Twitter -}}
|
|
|
|
{{- if not $pc.Disable -}}
|
2024-02-01 16:45:31 -05:00
|
|
|
{{- $id := or (.Get "id") "" -}}
|
|
|
|
{{- $user := or (.Get "user") "" -}}
|
|
|
|
{{- if and $id $user -}}
|
|
|
|
{{- template "render-simple-tweet" (dict "id" $id "user" $user "dnt" $pc.EnableDNT "name" .Name "position" .Position) -}}
|
2021-10-31 06:56:36 -04:00
|
|
|
{{- else -}}
|
2024-02-01 16:45:31 -05:00
|
|
|
{{- errorf "The %q shortcode requires two named parameters: user and id. See %s" .Name .Position -}}
|
2021-10-31 06:56:36 -04:00
|
|
|
{{- end -}}
|
2018-05-30 16:42:32 -04:00
|
|
|
{{- end -}}
|
2021-10-31 06:56:36 -04:00
|
|
|
|
|
|
|
{{- define "render-simple-tweet" -}}
|
|
|
|
{{- $url := printf "https://twitter.com/%v/status/%v" .user .id -}}
|
|
|
|
{{- $query := querify "url" $url "dnt" .dnt "omit_script" true -}}
|
|
|
|
{{- $request := printf "https://publish.twitter.com/oembed?%s" $query -}}
|
2024-02-01 16:45:31 -05:00
|
|
|
{{- with resources.GetRemote $request -}}
|
|
|
|
{{- with .Err -}}
|
|
|
|
{{- errorf "%s" . -}}
|
|
|
|
{{- else -}}
|
|
|
|
{{- (. | transform.Unmarshal).html | safeHTML -}}
|
|
|
|
{{- end -}}
|
|
|
|
{{- else -}}
|
|
|
|
{{- warnidf "shortcode-twitter-simple-getremote" "The %q shortcode was unable to retrieve the remote data. See %s" .name .position -}}
|
|
|
|
{{- end -}}
|
2018-05-30 16:42:32 -04:00
|
|
|
{{- end -}}
|
|
|
|
|
2021-10-31 06:56:36 -04:00
|
|
|
{{- define "__h_simple_twitter_css" -}}
|
|
|
|
{{- if not (.Page.Scratch.Get "__h_simple_twitter_css") -}}
|
|
|
|
{{/* Only include once */}}
|
2024-02-01 16:45:31 -05:00
|
|
|
{{- .Page.Scratch.Set "__h_simple_twitter_css" true -}}
|
2021-10-31 06:56:36 -04:00
|
|
|
<style type="text/css">
|
|
|
|
.twitter-tweet {
|
|
|
|
font: 14px/1.45 -apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Oxygen-Sans,Ubuntu,Cantarell,"Helvetica Neue",sans-serif;
|
|
|
|
border-left: 4px solid #2b7bb9;
|
|
|
|
padding-left: 1.5em;
|
|
|
|
color: #555;
|
|
|
|
}
|
|
|
|
.twitter-tweet a {
|
|
|
|
color: #2b7bb9;
|
|
|
|
text-decoration: none;
|
|
|
|
}
|
|
|
|
blockquote.twitter-tweet a:hover,
|
|
|
|
blockquote.twitter-tweet a:focus {
|
|
|
|
text-decoration: underline;
|
|
|
|
}
|
|
|
|
</style>
|
|
|
|
{{- end -}}
|
|
|
|
{{- end -}}
|