209 lines
6.1 KiB
Plaintext
209 lines
6.1 KiB
Plaintext
|
# encoding: utf-8
|
||
|
|
||
|
wb = xlsx_package.workbook
|
||
|
|
||
|
wb.add_worksheet(name: "Annoucement") do |sheet|
|
||
|
|
||
|
heading = sheet.styles.add_style(:b => true, :locked => true)
|
||
|
example = sheet.styles.add_style(:i => true)
|
||
|
row = []
|
||
|
row1 = []
|
||
|
row2 = []
|
||
|
|
||
|
row << t("category")
|
||
|
row1 << "select"
|
||
|
t = ""
|
||
|
categories = @module_app.categories.asc(:created_at)
|
||
|
categories.each_with_index do |cat,i|
|
||
|
t = t + "#{i}" + " -> " + cat.title + ", "
|
||
|
end
|
||
|
if categories.count > 0
|
||
|
t = t + " Example : 0"
|
||
|
else
|
||
|
t = "Leave this field blank"
|
||
|
end
|
||
|
row2 << t
|
||
|
|
||
|
row << t("tags")
|
||
|
row1 << "select"
|
||
|
t = ""
|
||
|
tags = @module_app.tags.asc(:created_at)
|
||
|
tags.each_with_index do |tag,i|
|
||
|
t = t + "#{i}" + " -> " + tag.name + ", "
|
||
|
end
|
||
|
if tags.count > 0
|
||
|
t = t + " Example : 0,1,2"
|
||
|
else
|
||
|
t = "Leave this field blank"
|
||
|
end
|
||
|
row2 << t
|
||
|
|
||
|
row << t("event_ann.start_date")
|
||
|
row1 << "date"
|
||
|
row2 << "Format: YYYY/MM/DD, Example: 2015/12/10"
|
||
|
|
||
|
row << t("event_ann.end_date")
|
||
|
row1 << "date"
|
||
|
row2 << "Format: YYYY/MM/DD, Example: 2015/12/12"
|
||
|
|
||
|
row << t("event_ann.event_date")
|
||
|
row1 << "date"
|
||
|
row2 << "Format: YYYY/MM/DD, Example: 2015/12/10"
|
||
|
|
||
|
row << t("top")
|
||
|
row1 << "boolean"
|
||
|
row2 << "0 for false, 1 for true"
|
||
|
|
||
|
row << t("hot")
|
||
|
row1 << "boolean"
|
||
|
row2 << "0 for false, 1 for true"
|
||
|
|
||
|
row << t("hide")
|
||
|
row1 << "boolean"
|
||
|
row2 << "0 for false, 1 for true "
|
||
|
|
||
|
row << t("image")
|
||
|
row1 << "url"
|
||
|
row2 << "http://www.example.com/images/example.png"
|
||
|
|
||
|
row << t("image") + " " + t("description") + " - " + t("en")
|
||
|
row1 << "textfield"
|
||
|
row2 << ""
|
||
|
row << t("image") + " " + t("description") + " - " + t("zh_tw")
|
||
|
row1 << "textfield"
|
||
|
row2 << ""
|
||
|
|
||
|
row << t("title") + " - " + t("en")
|
||
|
row1 << "textfield"
|
||
|
row2 << ""
|
||
|
row << t("title") + " - " + t("zh_tw")
|
||
|
row1 << "textfield"
|
||
|
row2 << ""
|
||
|
|
||
|
row << t("subtitle") + " - " + t("en")
|
||
|
row1 << "textarea"
|
||
|
row2 << ""
|
||
|
row << t("subtitle") + " - " + t("zh_tw")
|
||
|
row1 << "textarea"
|
||
|
row2 << ""
|
||
|
|
||
|
row << t("speaker") + " - " + t("en")
|
||
|
row1 << "textarea"
|
||
|
row2 << ""
|
||
|
row << t("speaker") + " - " + t("zh_tw")
|
||
|
row1 << "textarea"
|
||
|
row2 << ""
|
||
|
|
||
|
row << t("host") + " - " + t("en")
|
||
|
row1 << "textarea"
|
||
|
row2 << ""
|
||
|
row << t("host") + " - " + t("zh_tw")
|
||
|
row1 << "textarea"
|
||
|
row2 << ""
|
||
|
|
||
|
row << t("content") + " - " + t("en")
|
||
|
row1 << "editor"
|
||
|
row2 << ""
|
||
|
row << t("content") + " - " + t("zh_tw")
|
||
|
row1 << "editor"
|
||
|
row2 << ""
|
||
|
|
||
|
row << t("notes") + " - " + t("en")
|
||
|
row1 << "textarea"
|
||
|
row2 << ""
|
||
|
row << t("notes") + " - " + t("zh_tw")
|
||
|
row1 << "textarea"
|
||
|
row2 << ""
|
||
|
|
||
|
row << t("link")
|
||
|
row1 << "textfield"
|
||
|
row2 << "Seperate with ';'. Example: http://rulingcom.com; http://google.com"
|
||
|
|
||
|
row << t("link") + " " + t("url_alt") + " - " + t("en")
|
||
|
row1 << "textfield"
|
||
|
row2 << "Seperate with ';' with respective to the links in the link columns. Example : Rulingcom official site; Google search engine"
|
||
|
row << t("link") + " " + t("url_alt") + " - " + t("zh_tw")
|
||
|
row1 << "textfield"
|
||
|
row2 << "Seperate with ';' with respective to the links in the link columns. Example : Rulingcom official site; Google search engine"
|
||
|
|
||
|
row << t("file_")
|
||
|
row1 << "textfield"
|
||
|
row2 << "Seperate with ';'. Example: http://www.example.com/images/example.png; http://www.example.com/images/example2.png"
|
||
|
|
||
|
row << t("file_") + " " + t("description") + " - " + t("en")
|
||
|
row1 << "textfield"
|
||
|
row2 << "Seperate with ';' with respective to the links in the link columns. Example : Great view; Nice potrait"
|
||
|
row << t("file_") + " " + t("description") + " - " + t("zh_tw")
|
||
|
row1 << "textfield"
|
||
|
row2 << "Seperate with ';' with respective to the links in the link columns. Example : Great view; Nice potrait"
|
||
|
|
||
|
row << t("file_") + " " + t("alternative") + " - " + t("en")
|
||
|
row1 << "textfield"
|
||
|
row2 << "Seperate with ';' with respective to the links in the link columns. Example : example1; example2"
|
||
|
row << t("file_") + " " + t("alternative") + " - " + t("zh_tw")
|
||
|
row1 << "textfield"
|
||
|
row2 << "Seperate with ';' with respective to the links in the link columns. Example : example1; example2"
|
||
|
|
||
|
|
||
|
sheet.add_row row, :style => heading
|
||
|
sheet.add_row row1
|
||
|
sheet.add_row row2, :style => example
|
||
|
|
||
|
@event_anns.each do |eanns|
|
||
|
row = []
|
||
|
row << categories.to_a.index(eanns.category)
|
||
|
t = []
|
||
|
eanns.tags.each do |tag|
|
||
|
t << tags.to_a.index(tag)
|
||
|
end
|
||
|
row << t.join(",")
|
||
|
row << (eanns.postdate.strftime("%Y/%m/%d") rescue "")
|
||
|
row << (eanns.deadline.strftime("%Y/%m/%d") rescue "")
|
||
|
row << (eanns.eventdate.strftime("%Y/%m/%d") rescue "")
|
||
|
row << (eanns.is_top? ? 1 : 0)
|
||
|
row << (eanns.is_hot? ? 1 : 0)
|
||
|
row << (eanns.is_hidden? ? 1 : 0)
|
||
|
row << ("http://" + request.host_with_port + eanns.image.url rescue "")
|
||
|
row << eanns.image_description_translations["en"]
|
||
|
row << eanns.image_description_translations["zh_tw"]
|
||
|
row << eanns.title_translations["en"]
|
||
|
row << eanns.title_translations["zh_tw"]
|
||
|
row << eanns.subtitle_translations["en"]
|
||
|
row << eanns.subtitle_translations["zh_tw"]
|
||
|
row << eanns.speaker_translations["en"]
|
||
|
row << eanns.speaker_translations["zh_tw"]
|
||
|
row << eanns.host_translations["en"]
|
||
|
row << eanns.host_translations["zh_tw"]
|
||
|
row << eanns.text_translations["en"]
|
||
|
row << eanns.text_translations["zh_tw"]
|
||
|
row << eanns.notes_translations["en"]
|
||
|
row << eanns.notes_translations["zh_tw"]
|
||
|
|
||
|
links = eanns.bulletin_event_links.asc(:created_at)
|
||
|
t = links.collect{|l|l.url}
|
||
|
row << t.join(";")
|
||
|
t = links.collect{|l|l.title_translations["en"]}
|
||
|
row << t.join(";")
|
||
|
t = links.collect{|l|l.title_translations["zh_tw"]}
|
||
|
row << t.join(";")
|
||
|
|
||
|
files = eanns.bulletin_event_files.asc(:created_at)
|
||
|
t = files.collect{|f|("http://" + request.host_with_port + f.file.url rescue nil)}
|
||
|
t.delete(nil)
|
||
|
row << t.join(";")
|
||
|
t = files.collect{|l|l.description_translations["en"]}
|
||
|
row << t.join(";")
|
||
|
t = files.collect{|l|l.description_translations["zh_tw"]}
|
||
|
row << t.join(";")
|
||
|
t = files.collect{|l|l.title_translations["en"]}
|
||
|
row << t.join(";")
|
||
|
t = files.collect{|l|l.title_translations["zh_tw"]}
|
||
|
row << t.join(";")
|
||
|
sheet.add_row row
|
||
|
end
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
end
|