From 79f5bf991da4cf2fc7ca4ffa572b8cb42531fde6 Mon Sep 17 00:00:00 2001 From: Harry Bomrah Date: Thu, 25 Jan 2018 17:24:39 +0800 Subject: [PATCH] now supporting recruit module --- app/controllers/archives_controller.rb | 1 + app/models/archive_file.rb | 17 +++++++++++++++++ app/views/admin/archive_files/_form.html.erb | 10 ++++++++++ app/views/admin/archive_files/_index.html.erb | 2 +- 4 files changed, 29 insertions(+), 1 deletion(-) diff --git a/app/controllers/archives_controller.rb b/app/controllers/archives_controller.rb index d9910e0..2a09741 100644 --- a/app/controllers/archives_controller.rb +++ b/app/controllers/archives_controller.rb @@ -33,6 +33,7 @@ class ArchivesController < ApplicationController end { "archive-title" => archive.title, + "url" => archive.url, "statuses" => statuses, "sort_number" => archive.sort_number, "is_top" => (archive.is_top ? 1 : 0), diff --git a/app/models/archive_file.rb b/app/models/archive_file.rb index 42d9544..fcd9d63 100644 --- a/app/models/archive_file.rb +++ b/app/models/archive_file.rb @@ -18,6 +18,7 @@ class ArchiveFile field :title, as: :slug_title, localize: true + field :url, localize: true field :create_user_id field :update_user_id field :postdate , :type => DateTime, :default => Time.now @@ -39,6 +40,22 @@ class ArchiveFile after_save :save_archive_file_multiples + before_save :add_http + + protected + + def add_http + temp_url = {} + Site.first.in_use_locales.each do |locale| + locale = locale.to_s + temp_url[locale] = self.url_translations[locale] + unless /https?:\/\/[\S]+/.match(self.url_translations[locale]) || self.url_translations[locale].blank? + temp_url[locale] = 'http://' + self.url_translations[locale] + end + end + self.url_translations = temp_url + end + # def to_indexed_json # self.to_json # end diff --git a/app/views/admin/archive_files/_form.html.erb b/app/views/admin/archive_files/_form.html.erb index af2298a..0dc828b 100644 --- a/app/views/admin/archive_files/_form.html.erb +++ b/app/views/admin/archive_files/_form.html.erb @@ -121,6 +121,16 @@ <% end %> + +
+ +
+ <%= f.fields_for :url_translations do |f| %> + <%= f.text_field locale, class: "input-block-level", placeholder: t(:url), value: (@archive_file.url_translations[locale] rescue nil) %> + <% end %> +
+
+ diff --git a/app/views/admin/archive_files/_index.html.erb b/app/views/admin/archive_files/_index.html.erb index 902e03e..1a1a58c 100644 --- a/app/views/admin/archive_files/_index.html.erb +++ b/app/views/admin/archive_files/_index.html.erb @@ -30,7 +30,7 @@