mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-02-05 22:44:22 +08:00
Merge branch 'master' of https://github.com/biosistemika/scinote-web
This commit is contained in:
commit
dae5a661c9
3 changed files with 18 additions and 21 deletions
|
@ -97,21 +97,8 @@ module ReportsHelper
|
||||||
end
|
end
|
||||||
|
|
||||||
# "Hack" to omit file preview URL because of WKHTML issues
|
# "Hack" to omit file preview URL because of WKHTML issues
|
||||||
def report_image_asset_url(asset, type = :asset, klass = nil)
|
def report_image_asset_url(asset, _type = :asset, klass = nil)
|
||||||
prefix = ''
|
image_tag(asset.generate_base64(:medium), class: klass)
|
||||||
if ENV['PAPERCLIP_STORAGE'].present? &&
|
|
||||||
ENV['MAIL_SERVER_URL'].present? &&
|
|
||||||
ENV['PAPERCLIP_STORAGE'] == 'filesystem'
|
|
||||||
prefix = ENV['MAIL_SERVER_URL']
|
|
||||||
end
|
|
||||||
if !prefix.empty? &&
|
|
||||||
!prefix.include?('http://') &&
|
|
||||||
!prefix.include?('https://')
|
|
||||||
prefix = "http://#{prefix}"
|
|
||||||
end
|
|
||||||
size = type == :tiny_mce_asset ? :large : :medium
|
|
||||||
url = prefix + asset.url(size, timeout: Constants::URL_LONG_EXPIRE_TIME)
|
|
||||||
image_tag(url, class: klass)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# "Hack" to load Glyphicons css directly from the CDN
|
# "Hack" to load Glyphicons css directly from the CDN
|
||||||
|
|
|
@ -493,6 +493,16 @@ class Asset < ApplicationRecord
|
||||||
!locked? && %r{^image/#{Regexp.union(Constants::WHITELISTED_IMAGE_TYPES_EDITABLE)}} =~ file.content_type
|
!locked? && %r{^image/#{Regexp.union(Constants::WHITELISTED_IMAGE_TYPES_EDITABLE)}} =~ file.content_type
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def generate_base64(style)
|
||||||
|
image = if file.options[:storage].to_sym == :s3
|
||||||
|
URI.parse(url(style)).open.to_a.join
|
||||||
|
else
|
||||||
|
File.open(file.path(style)).to_a.join
|
||||||
|
end
|
||||||
|
encoded_data = Base64.strict_encode64(image)
|
||||||
|
"data:#{file_content_type};base64,#{encoded_data}"
|
||||||
|
end
|
||||||
|
|
||||||
protected
|
protected
|
||||||
|
|
||||||
# Checks if attachments is an image (in post processing imagemagick will
|
# Checks if attachments is an image (in post processing imagemagick will
|
||||||
|
|
12
db/schema.rb
12
db/schema.rb
|
@ -56,7 +56,7 @@ ActiveRecord::Schema.define(version: 20190520135317) do
|
||||||
t.datetime "updated_at", null: false
|
t.datetime "updated_at", null: false
|
||||||
t.string "file_file_name"
|
t.string "file_file_name"
|
||||||
t.string "file_content_type"
|
t.string "file_content_type"
|
||||||
t.integer "file_file_size"
|
t.bigint "file_file_size"
|
||||||
t.datetime "file_updated_at"
|
t.datetime "file_updated_at"
|
||||||
t.bigint "created_by_id"
|
t.bigint "created_by_id"
|
||||||
t.bigint "last_modified_by_id"
|
t.bigint "last_modified_by_id"
|
||||||
|
@ -169,7 +169,7 @@ ActiveRecord::Schema.define(version: 20190520135317) do
|
||||||
t.datetime "updated_at", null: false
|
t.datetime "updated_at", null: false
|
||||||
t.string "workflowimg_file_name"
|
t.string "workflowimg_file_name"
|
||||||
t.string "workflowimg_content_type"
|
t.string "workflowimg_content_type"
|
||||||
t.integer "workflowimg_file_size"
|
t.bigint "workflowimg_file_size"
|
||||||
t.datetime "workflowimg_updated_at"
|
t.datetime "workflowimg_updated_at"
|
||||||
t.uuid "uuid"
|
t.uuid "uuid"
|
||||||
t.index ["archived_by_id"], name: "index_experiments_on_archived_by_id"
|
t.index ["archived_by_id"], name: "index_experiments_on_archived_by_id"
|
||||||
|
@ -737,14 +737,14 @@ ActiveRecord::Schema.define(version: 20190520135317) do
|
||||||
t.datetime "updated_at", null: false
|
t.datetime "updated_at", null: false
|
||||||
t.string "file_file_name"
|
t.string "file_file_name"
|
||||||
t.string "file_content_type"
|
t.string "file_content_type"
|
||||||
t.integer "file_file_size"
|
t.bigint "file_file_size"
|
||||||
t.datetime "file_updated_at"
|
t.datetime "file_updated_at"
|
||||||
end
|
end
|
||||||
|
|
||||||
create_table "tiny_mce_assets", force: :cascade do |t|
|
create_table "tiny_mce_assets", force: :cascade do |t|
|
||||||
t.string "image_file_name"
|
t.string "image_file_name"
|
||||||
t.string "image_content_type"
|
t.string "image_content_type"
|
||||||
t.integer "image_file_size"
|
t.bigint "image_file_size"
|
||||||
t.datetime "image_updated_at"
|
t.datetime "image_updated_at"
|
||||||
t.integer "estimated_size", default: 0, null: false
|
t.integer "estimated_size", default: 0, null: false
|
||||||
t.integer "step_id"
|
t.integer "step_id"
|
||||||
|
@ -857,7 +857,7 @@ ActiveRecord::Schema.define(version: 20190520135317) do
|
||||||
t.datetime "updated_at", null: false
|
t.datetime "updated_at", null: false
|
||||||
t.string "avatar_file_name"
|
t.string "avatar_file_name"
|
||||||
t.string "avatar_content_type"
|
t.string "avatar_content_type"
|
||||||
t.integer "avatar_file_size"
|
t.bigint "avatar_file_size"
|
||||||
t.datetime "avatar_updated_at"
|
t.datetime "avatar_updated_at"
|
||||||
t.string "confirmation_token"
|
t.string "confirmation_token"
|
||||||
t.datetime "confirmed_at"
|
t.datetime "confirmed_at"
|
||||||
|
@ -924,7 +924,7 @@ ActiveRecord::Schema.define(version: 20190520135317) do
|
||||||
t.datetime "updated_at", null: false
|
t.datetime "updated_at", null: false
|
||||||
t.string "zip_file_file_name"
|
t.string "zip_file_file_name"
|
||||||
t.string "zip_file_content_type"
|
t.string "zip_file_content_type"
|
||||||
t.integer "zip_file_file_size"
|
t.bigint "zip_file_file_size"
|
||||||
t.datetime "zip_file_updated_at"
|
t.datetime "zip_file_updated_at"
|
||||||
t.string "type"
|
t.string "type"
|
||||||
t.index ["user_id"], name: "index_zip_exports_on_user_id"
|
t.index ["user_id"], name: "index_zip_exports_on_user_id"
|
||||||
|
|
Loading…
Reference in a new issue