From 8c75aab9b2ab0cc42ee054595aca0a3b83b19077 Mon Sep 17 00:00:00 2001 From: JiangRu Date: Tue, 6 Jan 2015 13:46:22 +0800 Subject: [PATCH] web_resource module --- app/models/web_link.rb | 3 +++ app/views/admin/web_resources/_form.html.erb | 8 ++++++++ config/locales/en.yml | 7 ++++++- config/locales/zh_tw.yml | 7 ++++++- lib/links.rb | 4 ---- .../{links_tasks.rake => web_resource_tasks.rake} | 0 lib/web_resource.rb | 4 ++++ lib/{links => web_resource}/engine.rb | 2 +- lib/{links => web_resource}/version.rb | 2 +- links.gemspec => web_resource.gemspec | 10 +++++----- 10 files changed, 34 insertions(+), 13 deletions(-) delete mode 100644 lib/links.rb rename lib/tasks/{links_tasks.rake => web_resource_tasks.rake} (100%) create mode 100644 lib/web_resource.rb rename lib/{links => web_resource}/engine.rb (97%) rename lib/{links => web_resource}/version.rb (55%) rename links.gemspec => web_resource.gemspec (69%) diff --git a/app/models/web_link.rb b/app/models/web_link.rb index 275185c..930aa46 100644 --- a/app/models/web_link.rb +++ b/app/models/web_link.rb @@ -15,6 +15,9 @@ class WebLink field :create_user_id field :update_user_id field :rss2_id, type: String + + field :link_open, type: String + LINK_OPEN_TYPES = ["local", "new_window"] scope :can_display, ->{where(is_hidden: false).order_by([:is_top,:desc],[:created_at,:desc])} diff --git a/app/views/admin/web_resources/_form.html.erb b/app/views/admin/web_resources/_form.html.erb index d229885..7dc01ea 100644 --- a/app/views/admin/web_resources/_form.html.erb +++ b/app/views/admin/web_resources/_form.html.erb @@ -116,6 +116,14 @@ + +
+ +
+ <%= f.select :link_open, WebLink::LINK_OPEN_TYPES.map{|wl| [t("web_link.#{wl}"), wl]} %> +
+
+ <% end %> diff --git a/config/locales/en.yml b/config/locales/en.yml index 67be665..92b7803 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -1,3 +1,8 @@ en: web_resource: Web resource - web_link: Web resource \ No newline at end of file + web_link: Web resource + + web_link: + local: Open In Current page + new_window: Open In New window + type: Link Open Type \ No newline at end of file diff --git a/config/locales/zh_tw.yml b/config/locales/zh_tw.yml index 94ca571..32628c7 100644 --- a/config/locales/zh_tw.yml +++ b/config/locales/zh_tw.yml @@ -1,3 +1,8 @@ zh_tw: web_resource: 網路資源 - web_link: 網路資源 \ No newline at end of file + web_link: 網路資源 + + web_link: + local: 當前視窗開啟 + new_window: 新視窗開啟 + type: 開啟方式 diff --git a/lib/links.rb b/lib/links.rb deleted file mode 100644 index 49dce3a..0000000 --- a/lib/links.rb +++ /dev/null @@ -1,4 +0,0 @@ -require "links/engine" - -module Links -end diff --git a/lib/tasks/links_tasks.rake b/lib/tasks/web_resource_tasks.rake similarity index 100% rename from lib/tasks/links_tasks.rake rename to lib/tasks/web_resource_tasks.rake diff --git a/lib/web_resource.rb b/lib/web_resource.rb new file mode 100644 index 0000000..e034a15 --- /dev/null +++ b/lib/web_resource.rb @@ -0,0 +1,4 @@ +require "web_resource/engine" + +module WebResource +end diff --git a/lib/links/engine.rb b/lib/web_resource/engine.rb similarity index 97% rename from lib/links/engine.rb rename to lib/web_resource/engine.rb index 19fbb0e..441c3a1 100644 --- a/lib/links/engine.rb +++ b/lib/web_resource/engine.rb @@ -2,7 +2,7 @@ module WebResource class Engine < ::Rails::Engine initializer "web_resource" do OrbitApp.registration "WebResource", :type => "ModuleApp" do - module_label "link" + module_label "web_resource.web_resource" base_url File.expand_path File.dirname(__FILE__) taggable "WebLink" diff --git a/lib/links/version.rb b/lib/web_resource/version.rb similarity index 55% rename from lib/links/version.rb rename to lib/web_resource/version.rb index 770bc75..bfe2c78 100644 --- a/lib/links/version.rb +++ b/lib/web_resource/version.rb @@ -1,3 +1,3 @@ -module Links +module WebResource VERSION = "0.0.1" end diff --git a/links.gemspec b/web_resource.gemspec similarity index 69% rename from links.gemspec rename to web_resource.gemspec index eff85e5..729a01a 100644 --- a/links.gemspec +++ b/web_resource.gemspec @@ -1,17 +1,17 @@ $:.push File.expand_path("../lib", __FILE__) # Maintain your gem's version: -require "links/version" +require "web_resource/version" # Describe your gem and declare its dependencies: Gem::Specification.new do |s| - s.name = "links" - s.version = Links::VERSION + s.name = "web_resource" + s.version = WebResource::VERSION s.authors = ["Ruling Digital"] s.email = ["orbit@rulingcom.com"] s.homepage = "http://www.rulingcom.com" - s.summary = "Create Web Resource of Links" - s.description = "Create a Web Resource of Links" + s.summary = "Web Resource for orbit" + s.description = "Web Resource for orbit" s.license = "MIT" s.files = Dir["{app,config,db,lib}/**/*", "MIT-LICENSE", "Rakefile", "README.rdoc"]