Fix host url.
This commit is contained in:
parent
179646fcfa
commit
8e75b19dd5
|
@ -144,6 +144,10 @@ class UniversalTablesController < ApplicationController
|
||||||
table = UTable.where(:category_id => params[:cat]).first rescue nil
|
table = UTable.where(:category_id => params[:cat]).first rescue nil
|
||||||
page = Page.where(:page_id => params[:page_id]).first
|
page = Page.where(:page_id => params[:page_id]).first
|
||||||
if !table.nil?
|
if !table.nil?
|
||||||
|
host_url = Site.first.root_url
|
||||||
|
if host_url == "http://"
|
||||||
|
host_url = request.protocol + request.host_with_port
|
||||||
|
end
|
||||||
@rows = []
|
@rows = []
|
||||||
@tablecolumns = table.table_columns.where(:display_in_index => true).asc(:order)
|
@tablecolumns = table.table_columns.where(:display_in_index => true).asc(:order)
|
||||||
entries = get_entries(params, table, page, false)
|
entries = get_entries(params, table, page, false)
|
||||||
|
@ -167,7 +171,7 @@ class UniversalTablesController < ApplicationController
|
||||||
text = format_date(ce.period_from, column.date_format) + " ~ " + format_date(ce.period_to, column.date_format)
|
text = format_date(ce.period_from, column.date_format) + " ~ " + format_date(ce.period_to, column.date_format)
|
||||||
text = "" if text.starts_with?(" ~")
|
text = "" if text.starts_with?(" ~")
|
||||||
when "image"
|
when "image"
|
||||||
text = "http://#{request.host_with_port}" + ce.image.thumb.url
|
text = host_url + ce.image.thumb.url
|
||||||
end
|
end
|
||||||
cols << {"text" => text}
|
cols << {"text" => text}
|
||||||
else
|
else
|
||||||
|
|
|
@ -8,8 +8,11 @@ namespace :universal_table_tasks do
|
||||||
I18n.locale = :zh_tw
|
I18n.locale = :zh_tw
|
||||||
table = UTable.find(id)
|
table = UTable.find(id)
|
||||||
ac = ActionController::Base.new()
|
ac = ActionController::Base.new()
|
||||||
url = "http://#{args.url}"
|
host_url = Site.first.root_url
|
||||||
xlsx = ac.render_to_string handlers: [:axlsx], formats: [:xlsx], template: "utable_export/export", locals: {table: table, site_in_use_locales: Site.first.in_use_locales, url: url}
|
if host_url == "http://"
|
||||||
|
host_url = "http://#{args.url}"
|
||||||
|
end
|
||||||
|
xlsx = ac.render_to_string handlers: [:axlsx], formats: [:xlsx], template: "utable_export/export", locals: {table: table, site_in_use_locales: Site.first.in_use_locales, url: host_url}
|
||||||
dirname = "public/uploads/utable_export/#{id}"
|
dirname = "public/uploads/utable_export/#{id}"
|
||||||
FileUtils.mkdir_p(dirname) unless File.exist?(dirname)
|
FileUtils.mkdir_p(dirname) unless File.exist?(dirname)
|
||||||
f = "#{dirname}/#{table.title.gsub(/[ "'*@#$%^&()+=;:.,?>|\\\/<~_!:,、。!?;「」〈〉【】/]/,'')}.xlsx"
|
f = "#{dirname}/#{table.title.gsub(/[ "'*@#$%^&()+=;:.,?>|\\\/<~_!:,、。!?;「」〈〉【】/]/,'')}.xlsx"
|
||||||
|
|
Loading…
Reference in New Issue