diff --git a/layouts/partials/papers/abstract.html b/layouts/partials/papers/abstract.html index 8582605770b0afebdf52c86b854f4694c807748a..324242e7f087ca41559b33c77153e51aaa43d345 100644 --- a/layouts/partials/papers/abstract.html +++ b/layouts/partials/papers/abstract.html @@ -1,10 +1,9 @@ <section> <p itemprop="abstract">{{ partial "PrepareHTML" .Params.Abstract }}</p> <div role="group"> - {{ if isset .Params "pdf" }} - {{- $pdf := partial "GetMedia" .Params.pdf -}} - <a href="{{ $pdf.url }}" download>{{ i18n "commons.download.pdf" }}</a><br> - {{ end }} - <a href="#" class="squared-button" download>PDF (435 ko)</a> + {{ partial "papers/actions.html" (dict + "paper" . + "only_file" true + ) }} </div> </section> diff --git a/layouts/partials/papers/actions.html b/layouts/partials/papers/actions.html new file mode 100644 index 0000000000000000000000000000000000000000..2a2f7ed9e72583e0cc069a478a9c8cce8f63761d --- /dev/null +++ b/layouts/partials/papers/actions.html @@ -0,0 +1,38 @@ +{{ $only_file := .only_file | default false }} +{{ with .paper }} + {{ $modalId := printf "modal-%s" .Slug }} + <div class="paper-actions" role="group"> + {{ if not $only_file }} + {{- if .Params.abstract -}} + <button class="squared-button" type="button" data-open-modal="{{ $modalId }}">{{ i18n "volumes.abstract" }}</button> + {{ partial "papers/modal.html" + (dict + "modalId" $modalId + "title" .Title + "abstract" .Params.abstract + ) }} + {{- end -}} + {{- end -}} + {{- if .Params.pdf -}} + {{- $file := partial "GetMedia" .Params.pdf -}} + {{- $size := partial "GetHumanSize" $file.size -}} + {{- $extension := partial "GetExtensionFile" $file.name -}} + {{- $extension_with_size := (printf "%.2f %s - %s" $size.weight $size.unit $extension) -}} + {{- $title_with_size := printf "%s (%s)" $file.name $extension_with_size -}} + {{- $url := $file.url -}} + {{- if site.Params.keycdn -}} + {{- $url = $file.direct_url -}} + {{- end -}} + {{ if $file }} + <figure> + <a href="{{ $url }}" download="{{ partial "PrepareHTML" $file.name }}" target="_blank" title="{{ i18n "commons.link.blank_aria" (dict "Title" $title_with_size) }}" class="squared-button"> + <figcaption> + <abbr title="{{ i18n (printf "commons.extensions.%s" $extension) }}">{{ $extension }}</abbr> + - {{ $size.weight }} <abbr title="{{ $size.full_unit }}">{{ $size.unit }}</abbr> + </figcaption> + </a> + </figure> + {{ end }} + {{- end -}} + </div> +{{ end }} \ No newline at end of file diff --git a/layouts/partials/papers/paper.html b/layouts/partials/papers/paper.html index 4ff65f0a842ffee07ac7a8e9a1585f9b3e8c31d5..3019c669e8247d3b94a01f271889622500b598f5 100644 --- a/layouts/partials/papers/paper.html +++ b/layouts/partials/papers/paper.html @@ -26,22 +26,6 @@ {{ end }} </p> </div> - <div class="paper-actions" role="group"> - <button class="squared-button" type="button" data-open-modal="{{ $modalId }}">{{ i18n "volumes.abstract" }}</button> - {{ if .Params.pdf }} - {{- $pdf := partial "GetMedia" .Params.pdf -}} - {{- $pdf_size := partial "GetHumanSize" $pdf.size -}} - <a href="{{ $pdf.url }}" download> - {{- i18n "commons.pdf_with_size" (dict "Size" $pdf_size) }} - </a> - {{ end }} - <a class="squared-button" href="#" download>PDF (435 ko)</a> - </div> - {{ partial "papers/modal.html" - (dict - "modalId" $modalId - "title" .Title - "abstract" .Params.abstract - ) }} + {{ partial "papers/actions.html" (dict "paper" . ) }} </article> {{ end }} \ No newline at end of file