Skip to content
Snippets Groups Projects
Commit a37c25d8 authored by Arnaud Levy's avatar Arnaud Levy
Browse files

attachment

parent 8c42f02d
No related branches found
No related tags found
No related merge requests found
......@@ -33,6 +33,10 @@ class Research::Journal::Volume < ApplicationRecord
scope :ordered, -> { order(number: :desc, published_at: :desc) }
def cover_path
"/assets/img/volumes/#{id}#{cover.filename.extension_with_delimiter}"
end
def to_s
"##{ number } #{ title }"
end
......@@ -48,6 +52,7 @@ class Research::Journal::Volume < ApplicationRecord
layout: false,
assigns: { volume: self }
)
github.send_file cover, cover_path if cover.attached?
end
def github
......
......@@ -32,6 +32,26 @@ class Github
rescue
end
def send_file(attachment, path)
begin
content = client.content repository, path: path
sha = content[:sha]
rescue
sha = nil
end
commit_message ||= "[file] Save #{ path }"
return if repository.blank?
path_without_slash = path[1..-1]
# local_path = attachment.download_blob_to_tempfile
client.create_contents repository,
path_without_slash,
commit_message,
attachment.download,
# file: local_path,
sha: sha
rescue
end
def read_file_at(path)
data = client.content repository, path: path
Base64.decode64 data.content
......
......@@ -10,7 +10,7 @@ tags:
- "economic growth"
lang: Français
date: "<%= @volume.published_at %>"
image: /assets/img/volume-1.png
image: "<%= @volume.cover_path %>"
articles:
<% @volume.articles.each do |article| %>
- <%= article.id %>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment