From 0a338399d32ae672307f6500df456a21c23c52d7 Mon Sep 17 00:00:00 2001 From: Manson Wang Date: Wed, 15 Jan 2014 19:25:03 +0800 Subject: [PATCH] Orbit WebResource Module --- .gitignore | 6 + Gemfile | 17 ++ MIT-LICENSE | 20 ++ README | 0 README.rdoc | 3 + Rakefile | 39 ++++ app/assets/images/web_resource/.gitkeep | 0 app/assets/stylesheets/web_resource/.gitkeep | 0 app/assets/stylesheets/web_resource/links.css | 90 +++++++++ app/controllers/.gitkeep | 0 app/controllers/application_controller.rb | 23 +++ .../back_end/web_link_categorys_controller.rb | 104 ++++++++++ .../back_end/web_links_controller.rb | 188 ++++++++++++++++++ .../front_end/web_links_controller.rb | 77 +++++++ .../widget/web_links_controller.rb | 71 +++++++ app/helpers/.gitkeep | 0 .../back_end/web_link_categorys_helper.rb | 13 ++ app/mailers/.gitkeep | 0 app/models/.gitkeep | 0 app/models/web_link.rb | 64 ++++++ app/models/web_link_category.rb | 27 +++ app/views/.gitkeep | 0 .../web_link_categorys/_form.html.erb | 30 +++ .../_web_link_category.html.erb | 19 ++ .../back_end/web_link_categorys/create.js.erb | 2 + .../web_link_categorys/destroy.js.erb | 1 + .../back_end/web_link_categorys/edit.js.erb | 1 + .../web_link_categorys/index.html.erb | 39 ++++ .../back_end/web_link_categorys/new.js.erb | 1 + .../web_link_categorys/quick_edit.js.erb | 3 + .../back_end/web_link_categorys/update.js.erb | 4 + .../web_links/_clear_filters.html.erb | 3 + .../back_end/web_links/_filter.html.erb | 11 + .../web_links/_filter_categories.html.erb | 6 + .../web_links/_filter_status.html.erb | 6 + .../back_end/web_links/_filter_tags.html.erb | 6 + .../back_end/web_links/_form.html.erb | 153 ++++++++++++++ .../back_end/web_links/_sort_headers.html.erb | 5 + .../back_end/web_links/_web_link.html.erb | 45 +++++ .../back_end/web_links/destroy.js.erb | 1 + .../back_end/web_links/edit.html.erb | 5 + .../back_end/web_links/index.html.erb | 44 ++++ .../back_end/web_links/index.js.erb | 3 + .../back_end/web_links/new.html.erb | 5 + .../back_end/web_links/show.html.erb | 0 .../back_end/web_links/toggle_enable.js.erb | 3 + .../front_end/web_links/index.html.erb | 36 ++++ .../front_end/web_links/index.js.erb | 1 + .../front_end/web_links/show.html.erb | 0 .../widget/web_links/_index.html.erb | 43 ++++ .../widget/web_links/_web_links.html.erb | 10 + .../widget/web_links/home_list.html.erb | 9 + .../widget/web_links/index.html.erb | 7 + .../widget/web_links/index.js.erb | 1 + .../widget/web_links/reload_web_links.js.erb | 1 + config/locales/en.yml | 15 ++ config/locales/zh_tw.yml | 15 ++ config/routes.rb | 23 +++ lib/tasks/web_resource_tasks.rake | 4 + lib/web_resource.rb | 4 + lib/web_resource/engine.rb | 73 +++++++ lib/web_resource/version.rb | 3 + script/rails | 6 + test/dummy/Rakefile | 7 + .../app/assets/javascripts/application.js | 9 + .../app/assets/stylesheets/application.css | 7 + .../app/controllers/application_controller.rb | 3 + test/dummy/app/helpers/application_helper.rb | 2 + test/dummy/app/mailers/.gitkeep | 0 test/dummy/app/models/.gitkeep | 0 .../app/views/layouts/application.html.erb | 14 ++ test/dummy/config.ru | 4 + test/dummy/config/application.rb | 45 +++++ test/dummy/config/boot.rb | 10 + test/dummy/config/database.yml | 25 +++ test/dummy/config/environment.rb | 5 + test/dummy/config/environments/development.rb | 30 +++ test/dummy/config/environments/production.rb | 60 ++++++ test/dummy/config/environments/test.rb | 39 ++++ .../initializers/backtrace_silencers.rb | 7 + test/dummy/config/initializers/inflections.rb | 10 + test/dummy/config/initializers/mime_types.rb | 5 + .../dummy/config/initializers/secret_token.rb | 7 + .../config/initializers/session_store.rb | 8 + .../config/initializers/wrap_parameters.rb | 14 ++ test/dummy/config/locales/en.yml | 5 + test/dummy/config/routes.rb | 58 ++++++ test/dummy/lib/assets/.gitkeep | 0 test/dummy/log/.gitkeep | 0 test/dummy/public/404.html | 26 +++ test/dummy/public/422.html | 26 +++ test/dummy/public/500.html | 26 +++ test/dummy/public/favicon.ico | 0 test/dummy/script/rails | 6 + test/integration/navigation_test.rb | 10 + test/test_helper.rb | 10 + test/web_resource_test.rb | 7 + web_resource.gemspec | 23 +++ web_resource.json | 12 ++ 99 files changed, 1909 insertions(+) create mode 100644 .gitignore create mode 100644 Gemfile create mode 100644 MIT-LICENSE create mode 100644 README create mode 100644 README.rdoc create mode 100644 Rakefile create mode 100644 app/assets/images/web_resource/.gitkeep create mode 100644 app/assets/stylesheets/web_resource/.gitkeep create mode 100644 app/assets/stylesheets/web_resource/links.css create mode 100644 app/controllers/.gitkeep create mode 100644 app/controllers/application_controller.rb create mode 100644 app/controllers/panel/web_resource/back_end/web_link_categorys_controller.rb create mode 100644 app/controllers/panel/web_resource/back_end/web_links_controller.rb create mode 100644 app/controllers/panel/web_resource/front_end/web_links_controller.rb create mode 100644 app/controllers/panel/web_resource/widget/web_links_controller.rb create mode 100644 app/helpers/.gitkeep create mode 100644 app/helpers/panel/web_resource/back_end/web_link_categorys_helper.rb create mode 100644 app/mailers/.gitkeep create mode 100644 app/models/.gitkeep create mode 100644 app/models/web_link.rb create mode 100644 app/models/web_link_category.rb create mode 100644 app/views/.gitkeep create mode 100644 app/views/panel/web_resource/back_end/web_link_categorys/_form.html.erb create mode 100644 app/views/panel/web_resource/back_end/web_link_categorys/_web_link_category.html.erb create mode 100644 app/views/panel/web_resource/back_end/web_link_categorys/create.js.erb create mode 100644 app/views/panel/web_resource/back_end/web_link_categorys/destroy.js.erb create mode 100644 app/views/panel/web_resource/back_end/web_link_categorys/edit.js.erb create mode 100644 app/views/panel/web_resource/back_end/web_link_categorys/index.html.erb create mode 100644 app/views/panel/web_resource/back_end/web_link_categorys/new.js.erb create mode 100644 app/views/panel/web_resource/back_end/web_link_categorys/quick_edit.js.erb create mode 100644 app/views/panel/web_resource/back_end/web_link_categorys/update.js.erb create mode 100644 app/views/panel/web_resource/back_end/web_links/_clear_filters.html.erb create mode 100644 app/views/panel/web_resource/back_end/web_links/_filter.html.erb create mode 100644 app/views/panel/web_resource/back_end/web_links/_filter_categories.html.erb create mode 100644 app/views/panel/web_resource/back_end/web_links/_filter_status.html.erb create mode 100644 app/views/panel/web_resource/back_end/web_links/_filter_tags.html.erb create mode 100644 app/views/panel/web_resource/back_end/web_links/_form.html.erb create mode 100644 app/views/panel/web_resource/back_end/web_links/_sort_headers.html.erb create mode 100644 app/views/panel/web_resource/back_end/web_links/_web_link.html.erb create mode 100644 app/views/panel/web_resource/back_end/web_links/destroy.js.erb create mode 100644 app/views/panel/web_resource/back_end/web_links/edit.html.erb create mode 100644 app/views/panel/web_resource/back_end/web_links/index.html.erb create mode 100644 app/views/panel/web_resource/back_end/web_links/index.js.erb create mode 100644 app/views/panel/web_resource/back_end/web_links/new.html.erb create mode 100644 app/views/panel/web_resource/back_end/web_links/show.html.erb create mode 100644 app/views/panel/web_resource/back_end/web_links/toggle_enable.js.erb create mode 100644 app/views/panel/web_resource/front_end/web_links/index.html.erb create mode 100644 app/views/panel/web_resource/front_end/web_links/index.js.erb create mode 100644 app/views/panel/web_resource/front_end/web_links/show.html.erb create mode 100644 app/views/panel/web_resource/widget/web_links/_index.html.erb create mode 100644 app/views/panel/web_resource/widget/web_links/_web_links.html.erb create mode 100644 app/views/panel/web_resource/widget/web_links/home_list.html.erb create mode 100644 app/views/panel/web_resource/widget/web_links/index.html.erb create mode 100644 app/views/panel/web_resource/widget/web_links/index.js.erb create mode 100644 app/views/panel/web_resource/widget/web_links/reload_web_links.js.erb create mode 100644 config/locales/en.yml create mode 100644 config/locales/zh_tw.yml create mode 100644 config/routes.rb create mode 100644 lib/tasks/web_resource_tasks.rake create mode 100644 lib/web_resource.rb create mode 100644 lib/web_resource/engine.rb create mode 100644 lib/web_resource/version.rb create mode 100644 script/rails create mode 100644 test/dummy/Rakefile create mode 100644 test/dummy/app/assets/javascripts/application.js create mode 100644 test/dummy/app/assets/stylesheets/application.css create mode 100644 test/dummy/app/controllers/application_controller.rb create mode 100644 test/dummy/app/helpers/application_helper.rb create mode 100644 test/dummy/app/mailers/.gitkeep create mode 100644 test/dummy/app/models/.gitkeep create mode 100644 test/dummy/app/views/layouts/application.html.erb create mode 100644 test/dummy/config.ru create mode 100644 test/dummy/config/application.rb create mode 100644 test/dummy/config/boot.rb create mode 100644 test/dummy/config/database.yml create mode 100644 test/dummy/config/environment.rb create mode 100644 test/dummy/config/environments/development.rb create mode 100644 test/dummy/config/environments/production.rb create mode 100644 test/dummy/config/environments/test.rb create mode 100644 test/dummy/config/initializers/backtrace_silencers.rb create mode 100644 test/dummy/config/initializers/inflections.rb create mode 100644 test/dummy/config/initializers/mime_types.rb create mode 100644 test/dummy/config/initializers/secret_token.rb create mode 100644 test/dummy/config/initializers/session_store.rb create mode 100644 test/dummy/config/initializers/wrap_parameters.rb create mode 100644 test/dummy/config/locales/en.yml create mode 100644 test/dummy/config/routes.rb create mode 100644 test/dummy/lib/assets/.gitkeep create mode 100644 test/dummy/log/.gitkeep create mode 100644 test/dummy/public/404.html create mode 100644 test/dummy/public/422.html create mode 100644 test/dummy/public/500.html create mode 100644 test/dummy/public/favicon.ico create mode 100644 test/dummy/script/rails create mode 100644 test/integration/navigation_test.rb create mode 100644 test/test_helper.rb create mode 100644 test/web_resource_test.rb create mode 100644 web_resource.gemspec create mode 100644 web_resource.json diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..1463de6 --- /dev/null +++ b/.gitignore @@ -0,0 +1,6 @@ +.bundle/ +log/*.log +pkg/ +test/dummy/db/*.sqlite3 +test/dummy/log/*.log +test/dummy/tmp/ \ No newline at end of file diff --git a/Gemfile b/Gemfile new file mode 100644 index 0000000..3dd698e --- /dev/null +++ b/Gemfile @@ -0,0 +1,17 @@ +source "http://rubygems.org" + +# Declare your gem's dependencies in web_resource.gemspec. +# Bundler will treat runtime dependencies like base dependencies, and +# development dependencies will be added by default to the :development group. +gemspec + +# jquery-rails is used by the dummy application +gem "jquery-rails" + +# Declare any dependencies that are still in development here instead of in +# your gemspec. These might include edge Rails or gems from your path or +# Git. Remember to move these dependencies to your gemspec before releasing +# your gem to rubygems.org. + +# To use debugger +# gem 'ruby-debug19', :require => 'ruby-debug' diff --git a/MIT-LICENSE b/MIT-LICENSE new file mode 100644 index 0000000..406f17b --- /dev/null +++ b/MIT-LICENSE @@ -0,0 +1,20 @@ +Copyright 2012 YOURNAME + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/README b/README new file mode 100644 index 0000000..e69de29 diff --git a/README.rdoc b/README.rdoc new file mode 100644 index 0000000..2764e5c --- /dev/null +++ b/README.rdoc @@ -0,0 +1,3 @@ += WebResource + +This project rocks and uses MIT-LICENSE. \ No newline at end of file diff --git a/Rakefile b/Rakefile new file mode 100644 index 0000000..d5065a3 --- /dev/null +++ b/Rakefile @@ -0,0 +1,39 @@ +#!/usr/bin/env rake +begin + require 'bundler/setup' +rescue LoadError + puts 'You must `gem install bundler` and `bundle install` to run rake tasks' +end +begin + require 'rdoc/task' +rescue LoadError + require 'rdoc/rdoc' + require 'rake/rdoctask' + RDoc::Task = Rake::RDocTask +end + +RDoc::Task.new(:rdoc) do |rdoc| + rdoc.rdoc_dir = 'rdoc' + rdoc.title = 'WebResource' + rdoc.options << '--line-numbers' + rdoc.rdoc_files.include('README.rdoc') + rdoc.rdoc_files.include('lib/**/*.rb') +end + +APP_RAKEFILE = File.expand_path("../test/dummy/Rakefile", __FILE__) +load 'rails/tasks/engine.rake' + + +Bundler::GemHelper.install_tasks + +require 'rake/testtask' + +Rake::TestTask.new(:test) do |t| + t.libs << 'lib' + t.libs << 'test' + t.pattern = 'test/**/*_test.rb' + t.verbose = false +end + + +task :default => :test diff --git a/app/assets/images/web_resource/.gitkeep b/app/assets/images/web_resource/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/app/assets/stylesheets/web_resource/.gitkeep b/app/assets/stylesheets/web_resource/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/app/assets/stylesheets/web_resource/links.css b/app/assets/stylesheets/web_resource/links.css new file mode 100644 index 0000000..cb3882c --- /dev/null +++ b/app/assets/stylesheets/web_resource/links.css @@ -0,0 +1,90 @@ +/* General style with default layout */ +.o-links {} +.o-links .o-links-group { + margin: 20px 0 0 0; + padding: 20px 0 0 0; + border-top: dashed 1px #EEE; +} +.o-links .o-links-group:first-child { + margin: 0; + padding: 0; + border: 0; +} +.o-links .o-links-category { + padding-bottom: 16px; + border-bottom: solid 2px #CCC; + font-weight: bold; + font-size: 1.2em; +} +.o-links .o-links-content {} +.o-links .o-links-content > ul { + margin: 0; + padding: 0; + list-style: none; +} +.o-links .o-links-content > ul > li { + margin-bottom: 30px; +} +.o-links .o-links-list {} +.o-links .o-links-list > ul {} +.o-links .o-links-list > ul > li { + padding: 10px 0 0 0; + margin: 10px 0 0 0; + border-top: solid 1px #eee; +} +.o-links .o-links-list > ul > li:first-child { + padding: 0; + margin: 0; + border: 0; +} +.o-links .o-links-title {} +.o-links .o-links-link { + font-weight: bold; +} +.o-links .o-links-link:hover {} +.o-links .o-links-description { + margin: 12px 0; + font-size: 0.85em; + line-height: 1.5em; +} + +.o-links .o-links-hot { + background-color: #D83131; + border-radius: 3px; + color: #FFFFFF; + display: inline-block; + font-size: 11px; + font-weight: normal; + line-height: 20px; + margin: 0 0 0 8px; + padding: 0 4px; + vertical-align: top; +} + +/* Tag list */ +.o-links .o-links-tag-list { + margin: 0 0 16px 0; +} +.o-links .o-links-tag-list ul { + margin: 0 -4px; + padding: 0; + list-style: none; +} +.o-links .o-links-tag-list ul:after { + content: "."; + clear: both; + display: block; + height: 0; + visibility: hidden; +} +.o-links .o-links-tag-list li { + float: left; + margin: 0 4px 8px 4px; +} +.o-links .o-links-tag { + display: block; + border: solid 1px #ccc; + padding: 4px; + font-size: 0.85em; +} +.o-links .o-links-tag:hover {} \ No newline at end of file diff --git a/app/controllers/.gitkeep b/app/controllers/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb new file mode 100644 index 0000000..307a4ac --- /dev/null +++ b/app/controllers/application_controller.rb @@ -0,0 +1,23 @@ +class ApplicationController < ActionController::Base + protect_from_forgery + before_filter :set_locale + + # Set I18n.locale + def set_locale + # update session if passed + session[:locale] = params[:locale] if params[:locale] + + # set locale based on session or default + begin + # check if locale is valid for non site pages + if !VALID_LOCALES.include?(session[:locale]) + I18n.locale = I18n.default_locale + else + I18n.locale = session[:locale] + end + rescue + I18n.locale = I18n.default_locale + end + end + +end diff --git a/app/controllers/panel/web_resource/back_end/web_link_categorys_controller.rb b/app/controllers/panel/web_resource/back_end/web_link_categorys_controller.rb new file mode 100644 index 0000000..310a6d9 --- /dev/null +++ b/app/controllers/panel/web_resource/back_end/web_link_categorys_controller.rb @@ -0,0 +1,104 @@ +class Panel::WebResource::BackEnd::WebLinkCategorysController < OrbitBackendController + before_filter :for_app_manager,:except => [:index] + include OrbitControllerLib::DivisionForDisable + + def index + @web_link_categorys = get_categories_for_index("WebLinkCategory") + @web_link_category = WebLinkCategory.new(:display => 'List') + + @url = panel_web_resource_back_end_web_link_categorys_path + + respond_to do |format| + format.html # index.html.erb + format.js + end + end + + # GET /web_links/1 + # GET /web_links/1.xml + def show + @web_link_category = WebLinkCategory.find(params[:id]) + + respond_to do |format| + format.html # show.html.erb + format.js + end + end + + # GET /web_links/new + # GET /web_links/new.xml + def new + @web_link_category = WebLinkCategory.new(:display => 'List') + + respond_to do |format| + format.html # new.html.erb + format.js + end + end + + # GET /web_links/1/edit + def edit + @web_link_category = WebLinkCategory.find(params[:id]) + + @url = panel_web_resource_back_end_web_link_category_path(@web_link_category) + + respond_to do |format| + format.html + format.js + end + end + + # POST /web_links + # POST /web_links.xml + def create + @web_link_category = WebLinkCategory.new(params[:web_link_category]) + + respond_to do |format| + if @web_link_category.save + format.html { redirect_to(panel_web_resource_back_end_web_link_categorys_url, :notice => t('web_link.create_web_link_category_success')) } + format.js + else + format.html { render :action => "new" } + format.js { render action: "new" } + end + end + end + + # PUT /web_links/1 + # PUT /web_links/1.xml + def update + @web_link_category = WebLinkCategory.find(params[:id]) + + @url = panel_web_resource_back_end_web_link_category_path(@web_link_category) + + respond_to do |format| + if @web_link_category.update_attributes(params[:web_link_category]) + format.html { redirect_to(panel_web_resource_back_end_web_link_categorys_url, :notice => t('web_link.update_web_link_category_success')) } + # format.xml { head :ok } + format.js + else + format.html { render :action => "edit" } + format.js { render :action => "edit" } + end + end + end + + # DELETE /web_links/1 + # DELETE /web_links/1.xml + def destroy + @web_link_category = WebLinkCategory.find(params[:id]) + @web_link_category.disable = @web_link_category.disable ? false : true + + if @web_link_category.save! + respond_to do |format| + format.html { redirect_to(panel_web_resource_back_end_web_link_categorys_url) } + # format.xml { head :ok } + format.js + end + else + flash[:error] = t("update.fail") + format.html { render :action => "index" } + end + + end +end diff --git a/app/controllers/panel/web_resource/back_end/web_links_controller.rb b/app/controllers/panel/web_resource/back_end/web_links_controller.rb new file mode 100644 index 0000000..3206a88 --- /dev/null +++ b/app/controllers/panel/web_resource/back_end/web_links_controller.rb @@ -0,0 +1,188 @@ +class Panel::WebResource::BackEnd::WebLinksController < OrbitBackendController + # include OrbitControllerLib::DivisionForDisable + # before_filter :for_app_manager,:except => [:index,:show] + + open_for_sub_manager :except => [:index] + # before_filter :only => [ :new,:edit,:update,:create] do |controller| + # controller.get_categorys('WebLinkCategory') + # end + + before_filter :only => [ :new, :create, :edit, :update ] do |controller| + @categories = get_categories_for_form + end + + def index + @tags = get_tags + @categories = get_categories_for_index + @statuses = get_statuses + category_ids = @categories.collect{|t| t.id} + + @web_links = get_sorted_and_filtered("web_link", :category_id.in => category_ids) + respond_to do |format| + format.html # index.html.erb + format.js { } + format.xml { render :xml => @web_links } + end + end + + # def index + + # get_categorys("WebLinkCategory",params[:web_link_category_id]) + # @filter = params[:filter] + # new_filter = params[:new_filter] + + # if @filter && params[:clear] + # @filter.delete(params[:type]) + # elsif @filter && new_filter + # if @filter.has_key?(new_filter[:type]) && @filter[new_filter[:type]].include?(new_filter[:id].to_s) + # @filter[new_filter[:type]].delete(new_filter[:id].to_s) + # elsif @filter.has_key?(new_filter[:type]) + # @filter[new_filter[:type]] << new_filter[:id].to_s + # else + # @filter.merge!({new_filter[:type] => [new_filter[:id].to_s]}) + # end + # elsif new_filter + # @filter = {new_filter[:type] => [new_filter[:id].to_s]} + # end + # @web_link_categories = get_categories_for_index("WebLinkCategory") + # @web_link_category_ids = @web_link_categories.collect{|t| t.id.to_s} + [nil] + + # # @web_links = WebLink.search(params[:category_id]) + # #@web_links = (params[:sort] || @filter) ? get_sorted_and_filtered_web_links : WebLink.all.page(params[:page]).per(10) + # @web_links = (params[:sort] || @filter) ? get_sorted_and_filtered("web_link",:web_link_category_id.in => @web_link_category_ids) : get_viewable("web_link",:web_link_category_id.in => @web_link_category_ids) + + # @tags = get_tags + + # respond_to do |format| + # format.html # index.html.erb + # format.xml { render :xml => @web_links } + # format.js + # end + # end + + # GET /web_links/1 + # GET /web_links/1.xml + def show + @web_link = WebLink.find(params[:id]) + respond_to do |format| + format.html # show.html.erb + format.xml { render :xml => @web_link } + end + end + + # GET /web_links/new + # GET /web_links/new.xml + def new + if(session[:in_validate_object].blank?) + @web_link = WebLink.new + else + @web_link = session[:in_validate_object] + session[:in_validate_object] = {} + end + + @tags = get_tags + + respond_to do |format| + format.html # new.html.erb + format.xml { render :xml => @web_link } + end + end + + # GET /web_links/1/edit + def edit + @web_link = WebLink.find(params[:id]) + if !current_user.admin? + redirect_to :action => :index + else + @tags = get_tags + end + end + + # POST /web_links + # POST /web_links.xml + def create + @web_link = WebLink.new(params[:web_link]) + @tags = get_tags + @web_link.create_user_id = current_user.id + @web_link.update_user_id = current_user.id + + respond_to do |format| + if @web_link.save + format.html { redirect_to(panel_web_resource_back_end_web_links_url) } + format.xml { render :xml => @web_link, :status => :created, :location => @web_link } + else + format.html { render :action => "new" } + format.xml { render :xml => @web_link.errors, :status => :unprocessable_entity } + end + end + end + + # PUT /web_links/1 + # PUT /web_links/1.xml + def update + @web_link = WebLink.find(params[:id]) + + @web_link.update_user_id = current_user.id + + params[:web_link][:tag_ids] ||=[] + + respond_to do |format| + if @web_link.update_attributes(params[:web_link]) + format.html { redirect_to(panel_web_resource_back_end_web_links_url) } + format.js { render 'toggle_enable' } + format.xml { head :ok } + else + format.html { render :action => "edit" } + format.xml { render :xml => @web_link.errors, :status => :unprocessable_entity } + end + end + end + + # DELETE /web_links/1 + # DELETE /web_links/1.xml + def destroy + @web_link = WebLink.find(params[:id]) + @web_link.destroy + + respond_to do |format| + format.html { redirect_to(panel_web_resource_back_end_web_links_url) } + # format.xml { head :ok } + format.js + end + end + + def delete + if params[:ids] + web_links = WebLink.any_in(:_id => params[:ids]).destroy_all + end + redirect_to panel_web_resource_back_end_web_links_url(:direction => params[:direction], :sort => params[:sort], :sort_options => params[:sort_options]) + end + + protected + + + # def get_index_categories(id = nil) + # @bulletin_categorys = [] + # if(is_manager? || is_admin?) + # @bulletin_categorys = (id ? BulletinCategory.admin_manager_all.find(id).to_a : BulletinCategory.admin_manager_all) + # elsif is_sub_manager? + # @bulletin_categorys = BulletinCategory.all + # end + # @bulletin_categorys + # end + + + # def get_categorys(id = nil) + # @web_link_categorys = [] + # if(is_manager? || is_admin?) + # @web_link_categorys = (id ? WebLinkCategory.admin_manager_all.find(id).to_a : WebLinkCategory.admin_manager_all)) + # elsif is_sub_manager? + # @web_link_categorys = WebLinkCategory.all.authed_for_user(current_user,'edit') + # end + # if @web_link_categorys.empty? && params[:action] != "index" + # flash[:alert] = t("announcement.error.no_avilb_cate_for_posting") + # redirect_to :action => :index + # end + # end + +end diff --git a/app/controllers/panel/web_resource/front_end/web_links_controller.rb b/app/controllers/panel/web_resource/front_end/web_links_controller.rb new file mode 100644 index 0000000..67e813d --- /dev/null +++ b/app/controllers/panel/web_resource/front_end/web_links_controller.rb @@ -0,0 +1,77 @@ +class Panel::WebResource::FrontEnd::WebLinksController < OrbitWidgetController + + def initialize + super + @app_title = 'web_resource' + end + + # GET /web_links + # GET /web_links.xml + + def index + + @item = Page.find(params[:page_id]) + + @title = @item.title + + if @item.frontend_data_count + @page_num = @item.frontend_data_count + else + @page_num = 4 + end + + date_now = Time.now + + # @web_link_categorys = get_categories_for_index + + if !params[:category_id].blank? + @web_link_categorys = @module_app.categories.enabled.any_in(:_id => params[:category_id]) + else + @web_link_categorys = @module_app.categories.enabled + end + + @web_link_datas = Array.new + + @web_link_categorys.each do |wlcg| + + if !params[:category_id].blank? && !params[:tag_id].blank? + @web_links = WebLink.all.can_display.where(:category_id.in => [wlcg.id], :tagged_ids.in => params[:tag_id]).desc( :is_top, :created_at ) + elsif !params[:category_id].blank? + @web_links = WebLink.all.can_display.where(:category_id.in => [wlcg.id]).desc( :is_top, :created_at ) + elsif !params[:tag_id].blank? + @web_links = WebLink.all.can_display.where(:category_id => wlcg.id, :tagged_ids.in => params[:tag_id]).desc( :is_top, :created_at ) + else + @web_links = WebLink.all.can_display.where(:category_id => wlcg.id).desc( :is_top, :created_at ) + end + + web_link_datas = Array.new + + @web_links.each do |wl| + web_link_datas << { + "title" => wl.title, + "is_hot" => (!wl.is_hot.blank? ? '1' : ''), + "context" => wl.context, + "url" => wl.url + } if !wl.blank? + end + + @web_link_datas << { "title" => wlcg.title, "web_links" => web_link_datas } if !@web_links.blank? + + end + + end + + def show + @item = Page.find(params[:page_id]) + @title = @item.title + @web_link = WebLink.find(params[:id]) + get_categorys + end + + protected + + def get_categorys + @web_link_categorys = WebLinkCategory.excludes('disabled' => true) + end + +end diff --git a/app/controllers/panel/web_resource/widget/web_links_controller.rb b/app/controllers/panel/web_resource/widget/web_links_controller.rb new file mode 100644 index 0000000..358ab9c --- /dev/null +++ b/app/controllers/panel/web_resource/widget/web_links_controller.rb @@ -0,0 +1,71 @@ +class Panel::WebResource::Widget::WebLinksController < OrbitWidgetController + + def initialize + super + @app_title = 'web_resource' + end + + # GET /web_links + # GET /web_links.xml + + def index + + @part = PagePart.find(params[:part_id]) + @title = @part.title_translations[I18n.locale.to_s] + + if @part.widget_data_count + @page_num = @part.widget_data_count + else + @page_num = 4 + end + + if @part.widget_field + @widget_fields = @part.widget_field + else + @widget_fields = [] + end + + @widget_style = @part.widget_style + + if !params[:category_id].blank? + @web_link_categorys = @module_app.categories.enabled.any_in(:_id => params[:category_id]) + else + @web_link_categorys = @module_app.categories.enabled + end + + @web_link_datas = Array.new + + @web_link_categorys.each do |wlcg| + + if !params[:category_id].blank? && !params[:tag_id].blank? + @web_links = WebLink.all.can_display.where(:category_id.in => [wlcg.id], :tagged_ids.in => params[:tag_id]).desc( :is_top, :created_at ).page( params[:page_main] ).per(@page_num) + elsif !params[:category_id].blank? + @web_links = WebLink.all.can_display.where(:category_id.in => [wlcg.id]).desc( :is_top, :created_at ).page( params[:page_main] ).per(@page_num) + elsif !params[:tag_id].blank? + @web_links = WebLink.all.can_display.where(:category_id => wlcg.id, :tagged_ids.in => params[:tag_id]).desc( :is_top, :created_at ).page( params[:page_main] ).per(@page_num) + else + @web_links = WebLink.all.can_display.where(:category_id => wlcg.id).desc( :is_top, :created_at ).page( params[:page_main] ).per(@page_num) + end + + web_link_datas = Array.new + + @web_links.each do |wl| + web_link_datas << { + "title" => wl.title, + "is_hot" => (!wl.is_hot.blank? ? '1' : ''), + "context" => wl.context, + "url" => wl.url + } if !wl.blank? + end + + @web_link_datas << { "title" => wlcg.title, "web_links" => web_link_datas } if !@web_links.blank? + + end + + end + + def get_categorys + @web_link_categorys = WebLinkCategory.excludes('disable' => true) + end + +end diff --git a/app/helpers/.gitkeep b/app/helpers/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/app/helpers/panel/web_resource/back_end/web_link_categorys_helper.rb b/app/helpers/panel/web_resource/back_end/web_link_categorys_helper.rb new file mode 100644 index 0000000..78e553c --- /dev/null +++ b/app/helpers/panel/web_resource/back_end/web_link_categorys_helper.rb @@ -0,0 +1,13 @@ +module Panel::WebResource::BackEnd::WebLinkCategorysHelper + include ActionView::Helpers::UrlHelper + + def show_web_link_permission_link(web_link) + type = 'edit' + oa = web_link.get_object_auth_by_title(type) + if oa.nil? + web_link.object_auths.new(title: type ).save + oa = web_link.get_object_auth_by_title(type) + end + link_to t(:category_auth),admin_object_auth_ob_auth_path(oa) + end +end \ No newline at end of file diff --git a/app/mailers/.gitkeep b/app/mailers/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/app/models/.gitkeep b/app/models/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/app/models/web_link.rb b/app/models/web_link.rb new file mode 100644 index 0000000..886f315 --- /dev/null +++ b/app/models/web_link.rb @@ -0,0 +1,64 @@ +# encoding: utf-8 +class WebLink + include Mongoid::Document + include Mongoid::Timestamps + include Mongoid::MultiParameterAttributes + + include OrbitCategory::Categorizable + include OrbitModel::LanguageRestrict + include OrbitModel::Status + include OrbitModel::TimeFrame + include OrbitTag::Taggable + + field :title, localize: true + field :context, localize: true + + field :url, localize: true + field :create_user_id + field :update_user_id, :class_name => "User" + + scope :can_display,where(is_hidden: false) + + # belongs_to :web_link_category + + before_save :clean_tags + + validates :title, :at_least_one => true + + before_validation :add_http + # validates :url, :presence => true, :format => /^(http|https):\/\/(([a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,5})|((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?))(:[0-9]{1,5})?(\/.*)?/i + + def self.search( category_id = nil ) + + if category_id.to_s.size > 0 + + find(:all, :conditions => {web_link_category_id: category_id}).desc( :is_top, :title ) + + else + + find(:all).desc( :is_top, :title) + + end + + end + + + def self.widget_datas + + where( :is_hidden => false ).desc(:is_top, :created_at) + + end + + protected + + def add_http + unless self.url[/^http:\/\//] || self.url[/^https:\/\//] + self.url = 'http://' + self.url + end + end + + def clean_tags + self.tagged_ids.delete('') + end + +end \ No newline at end of file diff --git a/app/models/web_link_category.rb b/app/models/web_link_category.rb new file mode 100644 index 0000000..0b2d3bc --- /dev/null +++ b/app/models/web_link_category.rb @@ -0,0 +1,27 @@ +# encoding: utf-8 + +class WebLinkCategory + include Mongoid::Document + include Mongoid::Timestamps + include OrbitCoreLib::ObjectAuthable + include OrbitCoreLib::ObjectDisable + # include Mongoid::MultiParameterAttributes + AfterObjectAuthUrl = '/panel/page_content/back_end/page_contexts' + APP_NAME = 'web_resource' + ObjectAuthTitlesOptions = %W{edit} + + field :key + + field :title, localize: true + + has_many :web_links + + def pp_object + title + end + + def self.from_id(id) + WebLinkCategory.find(id) rescue nil + end + +end \ No newline at end of file diff --git a/app/views/.gitkeep b/app/views/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/app/views/panel/web_resource/back_end/web_link_categorys/_form.html.erb b/app/views/panel/web_resource/back_end/web_link_categorys/_form.html.erb new file mode 100644 index 0000000..347c8b3 --- /dev/null +++ b/app/views/panel/web_resource/back_end/web_link_categorys/_form.html.erb @@ -0,0 +1,30 @@ +<% # encoding: utf-8 %> + +<%= form_for(@web_link_category, :remote => true, :url => @url) do |f| %> + +

<%= (@web_link_category.new_record? ? t(:add) : t(:edit)) %>

+ +
+ <%= f.label :key, t(:key) %> + <%= f.text_field :key %> +
+ +
+ <%= f.fields_for :title_translations do |f| %> + <% @site_in_use_locales.each do |locale| %> +
+ <%= label_tag "name-#{locale}", "#{t(:name)}-#{I18nVariable.from_locale(locale)}", :class => 'control-label' %> +
+ <%= f.text_field locale, :class => 'input-xxlarge', :value => (@web_link_category.title_translations[locale] rescue nil) %> +
+
+ <% end %> + <% end %> +
+ +
+ <%= f.submit t(:submit), :class=>'btn btn-primary' %> +
+ +<% end %> + \ No newline at end of file diff --git a/app/views/panel/web_resource/back_end/web_link_categorys/_web_link_category.html.erb b/app/views/panel/web_resource/back_end/web_link_categorys/_web_link_category.html.erb new file mode 100644 index 0000000..4c6af37 --- /dev/null +++ b/app/views/panel/web_resource/back_end/web_link_categorys/_web_link_category.html.erb @@ -0,0 +1,19 @@ + + + + + <%= web_link_category.key %> + <%if at_least_module_manager %> +
+ +
+ <% end -%> + + <% @site_in_use_locales.each do |locale| %> + <%= web_link_category.title_translations[locale] rescue nil %> + <% end %> + \ No newline at end of file diff --git a/app/views/panel/web_resource/back_end/web_link_categorys/create.js.erb b/app/views/panel/web_resource/back_end/web_link_categorys/create.js.erb new file mode 100644 index 0000000..de1f5f8 --- /dev/null +++ b/app/views/panel/web_resource/back_end/web_link_categorys/create.js.erb @@ -0,0 +1,2 @@ +$('<%= j render :partial => 'web_link_category', :collection => [@web_link_category] %>').appendTo('#web_link_categorys').hide().fadeIn(); +$("#new_web_link_category")[0].reset(); \ No newline at end of file diff --git a/app/views/panel/web_resource/back_end/web_link_categorys/destroy.js.erb b/app/views/panel/web_resource/back_end/web_link_categorys/destroy.js.erb new file mode 100644 index 0000000..fc1ed14 --- /dev/null +++ b/app/views/panel/web_resource/back_end/web_link_categorys/destroy.js.erb @@ -0,0 +1 @@ +$("#<%= dom_id @web_link_category %>").find(".archive_toggle").text("<%= show_toggle_archive_btn(@web_link_category) %> "); \ No newline at end of file diff --git a/app/views/panel/web_resource/back_end/web_link_categorys/edit.js.erb b/app/views/panel/web_resource/back_end/web_link_categorys/edit.js.erb new file mode 100644 index 0000000..eaff01f --- /dev/null +++ b/app/views/panel/web_resource/back_end/web_link_categorys/edit.js.erb @@ -0,0 +1 @@ +$("#form > form").replaceWith("<%= j render "form" %>"); \ No newline at end of file diff --git a/app/views/panel/web_resource/back_end/web_link_categorys/index.html.erb b/app/views/panel/web_resource/back_end/web_link_categorys/index.html.erb new file mode 100644 index 0000000..c72d1a8 --- /dev/null +++ b/app/views/panel/web_resource/back_end/web_link_categorys/index.html.erb @@ -0,0 +1,39 @@ + + +<%= flash_messages %> + + + + + + + <% @site_in_use_locales.each do |locale| %> + + <% end %> + + + + + <%= render :partial => 'web_link_category', :collection => @web_link_categorys %> + + + + +
<%= render :partial => "form" if at_least_module_manager%>
+ + diff --git a/app/views/panel/web_resource/back_end/web_link_categorys/new.js.erb b/app/views/panel/web_resource/back_end/web_link_categorys/new.js.erb new file mode 100644 index 0000000..40061b9 --- /dev/null +++ b/app/views/panel/web_resource/back_end/web_link_categorys/new.js.erb @@ -0,0 +1 @@ +$("#form > form").replaceWith("<%= j render "form" %>"); diff --git a/app/views/panel/web_resource/back_end/web_link_categorys/quick_edit.js.erb b/app/views/panel/web_resource/back_end/web_link_categorys/quick_edit.js.erb new file mode 100644 index 0000000..82c957e --- /dev/null +++ b/app/views/panel/web_resource/back_end/web_link_categorys/quick_edit.js.erb @@ -0,0 +1,3 @@ +$.each($(".quick_edit"),function(obj){ $(this).remove(); }); +$("#<%= dom_id @web_link_category %>").append("
<%= j render "form" %>
"); +//$("#form > form").replaceWith("<%= j render "form" %>"); diff --git a/app/views/panel/web_resource/back_end/web_link_categorys/update.js.erb b/app/views/panel/web_resource/back_end/web_link_categorys/update.js.erb new file mode 100644 index 0000000..b3a45bd --- /dev/null +++ b/app/views/panel/web_resource/back_end/web_link_categorys/update.js.erb @@ -0,0 +1,4 @@ +$("#<%= dom_id @web_link_category %>").replaceWith("<%= j render :partial => 'link_category', :collection => [@web_link_category] %>"); +<% @web_link_category = WebLinkCategory.new(:display => 'List') # reset for new form %> +$(".edit_web_link_category").replaceWith("<%= j render "form" %>") +$(".new_web_link_category")[0].reset(); \ No newline at end of file diff --git a/app/views/panel/web_resource/back_end/web_links/_clear_filters.html.erb b/app/views/panel/web_resource/back_end/web_links/_clear_filters.html.erb new file mode 100644 index 0000000..142e183 --- /dev/null +++ b/app/views/panel/web_resource/back_end/web_links/_clear_filters.html.erb @@ -0,0 +1,3 @@ +
+ <%= link_to content_tag(:i, nil, :class => 'icons-cycle') + t(:clear), panel_web_resource_back_end_web_links_path(:filter => @filter, :sort => params[:sort], :direction => params[:direction], :clear => true, :type => type), :class => "btn btn-small js_history" %> +
\ No newline at end of file diff --git a/app/views/panel/web_resource/back_end/web_links/_filter.html.erb b/app/views/panel/web_resource/back_end/web_links/_filter.html.erb new file mode 100644 index 0000000..63882b8 --- /dev/null +++ b/app/views/panel/web_resource/back_end/web_links/_filter.html.erb @@ -0,0 +1,11 @@ + + +<% content_for :page_specific_javascript do %> + <%= javascript_include_tag "sort_header" %> +<% end %> \ No newline at end of file diff --git a/app/views/panel/web_resource/back_end/web_links/_filter_categories.html.erb b/app/views/panel/web_resource/back_end/web_links/_filter_categories.html.erb new file mode 100644 index 0000000..f601e3b --- /dev/null +++ b/app/views/panel/web_resource/back_end/web_links/_filter_categories.html.erb @@ -0,0 +1,6 @@ +
+ <% @web_link_categories.each do |category| -%> + <%= link_to category.title, panel_web_resource_back_end_web_links_path(:filter => @filter, :new_filter => {:type => 'categories', :id => category.id}, :sort => params[:sort], :direction => params[:direction], :sort_options => params[:sort_options]), :class => "btn btn-small js_history#{is_filter_active?('categories', category.id)}" %> + <% end -%> +
+<%= render :partial => 'clear_filters', :locals => {:type => 'categories'} %> \ No newline at end of file diff --git a/app/views/panel/web_resource/back_end/web_links/_filter_status.html.erb b/app/views/panel/web_resource/back_end/web_links/_filter_status.html.erb new file mode 100644 index 0000000..a138f52 --- /dev/null +++ b/app/views/panel/web_resource/back_end/web_links/_filter_status.html.erb @@ -0,0 +1,6 @@ +
+ <%= link_to t(:top), panel_web_resource_back_end_web_links_path(:filter => @filter, :new_filter => {:type => 'status', :id => 'is_top'}, :sort => params[:sort], :direction => params[:direction], :sort_options => params[:sort_options]), :class => "btn btn-small js_history#{is_filter_active?('status', 'is_top')}" %> + <%= link_to t(:hot), panel_web_resource_back_end_web_links_path(:filter => @filter, :new_filter => {:type => 'status', :id => 'is_hot'}, :sort => params[:sort], :direction => params[:direction], :sort_options => params[:sort_options]), :class => "btn btn-small js_history#{is_filter_active?('status', 'is_hot')}" %> + <%= link_to t(:hidden), panel_web_resource_back_end_web_links_path(:filter => @filter, :new_filter => {:type => 'status', :id => 'is_hidden'}, :sort => params[:sort], :direction => params[:direction], :sort_options => params[:sort_options]), :class => "btn btn-small js_history#{is_filter_active?('status', 'is_hidden')}" unless(is_guest?)%> +
+<%= render :partial => 'clear_filters', :locals => {:type => 'status'} %> \ No newline at end of file diff --git a/app/views/panel/web_resource/back_end/web_links/_filter_tags.html.erb b/app/views/panel/web_resource/back_end/web_links/_filter_tags.html.erb new file mode 100644 index 0000000..1cd2190 --- /dev/null +++ b/app/views/panel/web_resource/back_end/web_links/_filter_tags.html.erb @@ -0,0 +1,6 @@ +
+ <% @tags.each do |tag| -%> + <%= link_to tag[I18n.locale], panel_web_resource_back_end_web_links_path(:filter => @filter, :new_filter => {:type => 'tags', :id => tag.id}, :sort => params[:sort], :direction => params[:direction], :sort_options => params[:sort_options]), :class => "btn btn-small js_history#{is_filter_active?('tags', tag.id)}" %> + <% end -%> +
+<%= render :partial => 'clear_filters', :locals => {:type => 'tags'} %> \ No newline at end of file diff --git a/app/views/panel/web_resource/back_end/web_links/_form.html.erb b/app/views/panel/web_resource/back_end/web_links/_form.html.erb new file mode 100644 index 0000000..c614e75 --- /dev/null +++ b/app/views/panel/web_resource/back_end/web_links/_form.html.erb @@ -0,0 +1,153 @@ +<% # encoding: utf-8 %> +<% content_for :page_specific_css do %> + <%= stylesheet_link_tag "lib/main-forms" %> + <%= stylesheet_link_tag "lib/fileupload" %> +<% end %> +<% content_for :page_specific_javascript do %> + <%= javascript_include_tag "lib/bootstrap-fileupload" %> + <%= javascript_include_tag "lib/module-area" %> +<% end %> + + <%= f.error_messages %> + + +
+ + + + + + +
+ + +
+ + +
+ +
+ <%= f.select :category_id, @categories.collect{|t| [ t.title, t.id ]} %> +
+
+ +
+ + + <% if show_form_status_field(@web_link) %> +
+ + +
+ +
+ + + +
+
+ +
+ <% end %> + + +
+ + +
+ +
+ <% @tags.each do |tag| %> + + <% end %> +
+
+ +
+ +
+ + + + + + +
+ + <% @site_in_use_locales.each_with_index do |locale, i| %> + +
"> + + +
+ +
+ <%= f.fields_for :title_translations do |f| %> + <%= f.text_field locale, class: "input-block-level", placeholder: t(:title), value: (@web_link.title_translations[locale] rescue nil) %> + <% end %> +
+
+ + +
+ +
+ <%= f.fields_for :context_translations do |f| %> + <%= f.text_area locale, rows: 5, class: "input-block-level", value: (@web_link.context_translations[locale] rescue nil) %> + <% end %> +
+
+ + +
+ +
+ <%= f.fields_for :url_translations do |f| %> + <%= f.text_field locale, class: "input-block-level", placeholder: t(:url), value: (@web_link.url_translations[locale] rescue nil) %> + <% end %> +
+
+ +
+ + <% end %> + + +
+ +
+ + +
+ <%= hidden_field_tag 'page', params[:page] if !params[:page].blank? %> + <%= f.submit t('submit'), class: 'btn btn-primary' %> + <%= link_to t('cancel'), get_go_back, :class=>"btn" %> +
diff --git a/app/views/panel/web_resource/back_end/web_links/_sort_headers.html.erb b/app/views/panel/web_resource/back_end/web_links/_sort_headers.html.erb new file mode 100644 index 0000000..87e9eb0 --- /dev/null +++ b/app/views/panel/web_resource/back_end/web_links/_sort_headers.html.erb @@ -0,0 +1,5 @@ +<%= render_sort_bar(true, delete_panel_web_resource_back_end_web_links_path(:direction => params[:direction], :sort => params[:sort], :sort_options => params[:sort_options]), + ['status', ['is_top', 'is_hot', 'is_hidden', 'is_pending', 'is_checked', 'is_rejected'], 'span1', :status], + ['category', 'bulletin_category', 'span2', :category], + ['title', 'title','span3', :title], + ['tags', 'tags', 'span2', :tags]).html_safe %> \ No newline at end of file diff --git a/app/views/panel/web_resource/back_end/web_links/_web_link.html.erb b/app/views/panel/web_resource/back_end/web_links/_web_link.html.erb new file mode 100644 index 0000000..6e8920a --- /dev/null +++ b/app/views/panel/web_resource/back_end/web_links/_web_link.html.erb @@ -0,0 +1,45 @@ + + + <% if (web_link.create_user_id == current_or_guest_user.id) || is_manager? %> + <%= check_box_tag 'to_delete[]', web_link.id, false, :class => "checkbox_in_list" %> + <% end -%> + + +
+
+ <% if web_link.is_top? %> + <%= t(:top) %> + <% end %> + <% if web_link.is_hot? %> + <%= t(:hot) %> + <% end %> + <% if web_link.is_hidden? %> + <%= t(:hidden) %> + <% end %> +
+
+ + <%= web_link.web_link_category.title rescue nil %> + + <%#= link_to web_link.title, panel_web_resource_back_end_web_link_path(web_link) %> + <%= link_to web_link.title, web_link.url, {:target => '_blank', :title => web_link.title} %> +
+ +
+ + +
+
+ <% web_link.sorted_tags.each do |tag| %> + <%= tag.name %> + <% end %> +
+
+ + + diff --git a/app/views/panel/web_resource/back_end/web_links/destroy.js.erb b/app/views/panel/web_resource/back_end/web_links/destroy.js.erb new file mode 100644 index 0000000..b0fbcf1 --- /dev/null +++ b/app/views/panel/web_resource/back_end/web_links/destroy.js.erb @@ -0,0 +1 @@ +$("#<%= dom_id @web_link %>").remove(); \ No newline at end of file diff --git a/app/views/panel/web_resource/back_end/web_links/edit.html.erb b/app/views/panel/web_resource/back_end/web_links/edit.html.erb new file mode 100644 index 0000000..1b6a4cf --- /dev/null +++ b/app/views/panel/web_resource/back_end/web_links/edit.html.erb @@ -0,0 +1,5 @@ +<%= form_for @web_link, url: panel_web_resource_back_end_web_link_path(@web_link), html: {class: "form-horizontal main-forms previewable"} do |f| %> +
+ <%= render partial: 'form', locals: {f: f} %> +
+<% end %> \ No newline at end of file diff --git a/app/views/panel/web_resource/back_end/web_links/index.html.erb b/app/views/panel/web_resource/back_end/web_links/index.html.erb new file mode 100644 index 0000000..e11294f --- /dev/null +++ b/app/views/panel/web_resource/back_end/web_links/index.html.erb @@ -0,0 +1,44 @@ +<% set_default_index do + objects @web_links + quick_edit_link type: 'edit', + link: 'edit_panel_web_resource_back_end_web_link_path' + quick_edit_link type: 'detail' + quick_edit_link type: 'delete', + link: 'panel_web_resource_back_end_web_link_path' + field type: 'status', + db_field: @statuses, + translation: 'status', + hide: 'phone', + sort: 'status', + header_class: 'span2' + field type: 'associated', + db_field: 'category', + model_field: 'title', + translation: 'category', + hide: 'phone', + sort: 'category', + header_class: 'span2' + field db_field: 'title', + translation: 'title', + sort: 'title', + display_option: 'link_to value, panel_web_resource_front_end_web_link_path(object)', + quick_edit: true, + header_class: 'span5' + field type: 'tags', + hide: 'all', + sort: 'tags' + filter_field type: 'array', + values: @statuses, + translation: 'status' + filter_field type: 'objects', + values: @categories, + translation: 'category', + object_field: 'title' + filter_field type: 'objects', + values: @tags, + translation: 'tags', + object_field: 'name' + footer link: 'new_panel_web_resource_back_end_web_link_path' +end %> + +<%= render 'admin/default_index/index' %> diff --git a/app/views/panel/web_resource/back_end/web_links/index.js.erb b/app/views/panel/web_resource/back_end/web_links/index.js.erb new file mode 100644 index 0000000..abf256e --- /dev/null +++ b/app/views/panel/web_resource/back_end/web_links/index.js.erb @@ -0,0 +1,3 @@ +$("#sort_headers").html("<%= j render 'sort_headers' %>"); +$("#tbody_web_links").html("<%= j render :partial => 'web_link', :collection => @web_links %>"); +$("#web_link_pagination").html("<%= j paginate @web_links, :params => {:direction => params[:direction], :sort => params[:sort], :filter => @filter, :new_filter => nil} %>"); \ No newline at end of file diff --git a/app/views/panel/web_resource/back_end/web_links/new.html.erb b/app/views/panel/web_resource/back_end/web_links/new.html.erb new file mode 100644 index 0000000..73bd91d --- /dev/null +++ b/app/views/panel/web_resource/back_end/web_links/new.html.erb @@ -0,0 +1,5 @@ +<%= form_for @web_link, url: panel_web_resource_back_end_web_links_path, html: {class: "form-horizontal main-forms previewable"} do |f| %> +
+ <%= render partial: 'form', locals: {f: f} %> +
+<% end %> diff --git a/app/views/panel/web_resource/back_end/web_links/show.html.erb b/app/views/panel/web_resource/back_end/web_links/show.html.erb new file mode 100644 index 0000000..e69de29 diff --git a/app/views/panel/web_resource/back_end/web_links/toggle_enable.js.erb b/app/views/panel/web_resource/back_end/web_links/toggle_enable.js.erb new file mode 100644 index 0000000..b00cfa0 --- /dev/null +++ b/app/views/panel/web_resource/back_end/web_links/toggle_enable.js.erb @@ -0,0 +1,3 @@ +$("#enable_<%= @bulletin.id %>").toggle(); +$("#disable_<%= @bulletin.id %>").toggle(); +$("#bulletin_<%= @bulletin.id %>").toggleClass('disable'); \ No newline at end of file diff --git a/app/views/panel/web_resource/front_end/web_links/index.html.erb b/app/views/panel/web_resource/front_end/web_links/index.html.erb new file mode 100644 index 0000000..64660c0 --- /dev/null +++ b/app/views/panel/web_resource/front_end/web_links/index.html.erb @@ -0,0 +1,36 @@ +<% # encoding: utf-8 %> + + + +<%#= paginate @web_links, :param_name => :page_main, :params => {:inner => false}%> + +<%#= stylesheet_link_tag "web_resource/links" %> diff --git a/app/views/panel/web_resource/front_end/web_links/index.js.erb b/app/views/panel/web_resource/front_end/web_links/index.js.erb new file mode 100644 index 0000000..c5efda6 --- /dev/null +++ b/app/views/panel/web_resource/front_end/web_links/index.js.erb @@ -0,0 +1 @@ +alert('bob'); \ No newline at end of file diff --git a/app/views/panel/web_resource/front_end/web_links/show.html.erb b/app/views/panel/web_resource/front_end/web_links/show.html.erb new file mode 100644 index 0000000..e69de29 diff --git a/app/views/panel/web_resource/widget/web_links/_index.html.erb b/app/views/panel/web_resource/widget/web_links/_index.html.erb new file mode 100644 index 0000000..b6a5218 --- /dev/null +++ b/app/views/panel/web_resource/widget/web_links/_index.html.erb @@ -0,0 +1,43 @@ +<% # encoding: utf-8 %> +<% if @title %> +

<%= @title %>

+<% end %> + + + +
+<% if !params[:category_id].blank? %> +<%= link_to t(:more_plus), panel_web_resource_front_end_web_links_path(:category_id => @part.category) %> +<% else %> +<%= link_to t(:more_plus), panel_web_resource_front_end_web_links_path %> +<% end %> +
diff --git a/app/views/panel/web_resource/widget/web_links/_web_links.html.erb b/app/views/panel/web_resource/widget/web_links/_web_links.html.erb new file mode 100644 index 0000000..cc612c5 --- /dev/null +++ b/app/views/panel/web_resource/widget/web_links/_web_links.html.erb @@ -0,0 +1,10 @@ + + + \ No newline at end of file diff --git a/app/views/panel/web_resource/widget/web_links/home_list.html.erb b/app/views/panel/web_resource/widget/web_links/home_list.html.erb new file mode 100644 index 0000000..1f9fd30 --- /dev/null +++ b/app/views/panel/web_resource/widget/web_links/home_list.html.erb @@ -0,0 +1,9 @@ + diff --git a/app/views/panel/web_resource/widget/web_links/index.html.erb b/app/views/panel/web_resource/widget/web_links/index.html.erb new file mode 100644 index 0000000..3303634 --- /dev/null +++ b/app/views/panel/web_resource/widget/web_links/index.html.erb @@ -0,0 +1,7 @@ + + + + +<%#= stylesheet_link_tag "web_resource/links" %> \ No newline at end of file diff --git a/app/views/panel/web_resource/widget/web_links/index.js.erb b/app/views/panel/web_resource/widget/web_links/index.js.erb new file mode 100644 index 0000000..4ca2c87 --- /dev/null +++ b/app/views/panel/web_resource/widget/web_links/index.js.erb @@ -0,0 +1 @@ +$('#web_link_widget').html("<%= j render 'index' %>") \ No newline at end of file diff --git a/app/views/panel/web_resource/widget/web_links/reload_web_links.js.erb b/app/views/panel/web_resource/widget/web_links/reload_web_links.js.erb new file mode 100644 index 0000000..a457732 --- /dev/null +++ b/app/views/panel/web_resource/widget/web_links/reload_web_links.js.erb @@ -0,0 +1 @@ +$('#web_links_links').html("<%= j render 'web_links' if @web_links %>") \ No newline at end of file diff --git a/config/locales/en.yml b/config/locales/en.yml new file mode 100644 index 0000000..e5eac0c --- /dev/null +++ b/config/locales/en.yml @@ -0,0 +1,15 @@ +en: + + web_resource: + web_link: Web resource + frontend: + web_link: Web resource Front-end + widget: + index: Web resource Widget + + web_link: + create_web_link_category_success: Web resource category was successfully created + editing_web_resource: Editing web resource + list_of_web_resource: Web resource list + new_web_resource: New web resource + update_web_link_category_success: Web resource was successfully updated diff --git a/config/locales/zh_tw.yml b/config/locales/zh_tw.yml new file mode 100644 index 0000000..b49e780 --- /dev/null +++ b/config/locales/zh_tw.yml @@ -0,0 +1,15 @@ +zh_tw: + + web_resource: + web_link: 網路資源 + frontend: + web_link: 網路資源前台 + widget: + index: 網路資源Widget + + web_link: + create_web_link_category_success: 網路資源類別已成功建立 + editing_web_resource: 編輯網路資源 + list_of_web_resource: 網路資源列表 + new_web_resource: 新增網路資源 + update_web_link_category_success: 網路資源已成功更新 diff --git a/config/routes.rb b/config/routes.rb new file mode 100644 index 0000000..0ab9fa1 --- /dev/null +++ b/config/routes.rb @@ -0,0 +1,23 @@ +Rails.application.routes.draw do + namespace :panel do + namespace :web_resource do + namespace :back_end do + resources :web_links do + collection do + get 'delete' + end + end + resources :web_link_categorys + resources :tags + end + namespace :front_end do + match "web_links" => "web_links#index" + resources :web_links + end + namespace :widget do + match "index" => "web_links#index" + end + end + end + match "/appfront/*path" => redirect("/panel/*path") +end diff --git a/lib/tasks/web_resource_tasks.rake b/lib/tasks/web_resource_tasks.rake new file mode 100644 index 0000000..964a312 --- /dev/null +++ b/lib/tasks/web_resource_tasks.rake @@ -0,0 +1,4 @@ +# desc "Explaining what the task does" +# task :web_resource do +# # Task goes here +# end 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/web_resource/engine.rb b/lib/web_resource/engine.rb new file mode 100644 index 0000000..c4ee7c1 --- /dev/null +++ b/lib/web_resource/engine.rb @@ -0,0 +1,73 @@ +module WebResource + class Engine < Rails::Engine + initializer "web_resource" do + OrbitApp.registration "WebResource",:type=> 'ModuleApp' do + module_label 'link' + base_url File.expand_path File.dirname(__FILE__) + # personal_plugin :enable => true,:path=>"panel/web_resource/plugin/profile",:i18n=>'admin.web_resource' + + version "0.1" + organization "Rulingcom" + author "RD dep" + intro "I am intro" + update_info 'some update_info' + + front_end do + app_page 'web_links' do + frontend_i18n "web_resource.frontend.web_link" + end + end + + authorizable + categorizable + taggable + + widgets do + # default_widget do + # query 'Bulletin.all' + # image :image + # end + + categories_query 'WebLinkCategory.all' + tags_query 'WebResourceTag.all' + + customize_widget "index" do + widget_i18n "web_resource.widget.index" + end + end + + side_bar do + head_label_i18n 'link',:icon_class=>"icons-link" + available_for [:admin,:guest,:manager,:sub_manager] + active_for_controllers ({:private=>['web_links', 'web_link_categorys','module_tags', 'categories']}) + active_for_object_auth ['WebLinkCategory'] + + head_link_path "panel_web_resource_back_end_web_links_path" + + context_link 'list_', + :link_path=>"panel_web_resource_back_end_web_links_path" , + :priority=>1, + :active_for_action=>{:web_links=>:index}, + :available_for => [:all] + + context_link 'add', + :link_path=>"new_panel_web_resource_back_end_web_link_path" , + :priority=>2, + :active_for_action=>{:web_links=>:new}, + :available_for => [:sub_manager] + context_link 'categories', + :link_path=>"admin_module_app_categories_path(get_module_app)" , + :priority=>3, + :active_for_category => 'WebResource', + :available_for => [:manager] + + context_link 'tags', + :link_path=>"admin_module_tags_path(:module_app_id => ModuleApp.first(conditions: {title: 'WebResource'}))" , + :priority=>4, + :active_for_tag => 'WebResource', + :available_for => [:manager] + end + end + end + end +end diff --git a/lib/web_resource/version.rb b/lib/web_resource/version.rb new file mode 100644 index 0000000..bfe2c78 --- /dev/null +++ b/lib/web_resource/version.rb @@ -0,0 +1,3 @@ +module WebResource + VERSION = "0.0.1" +end diff --git a/script/rails b/script/rails new file mode 100644 index 0000000..23bd81f --- /dev/null +++ b/script/rails @@ -0,0 +1,6 @@ +#!/usr/bin/env ruby.exe +#!/usr/bin/env ruby +# This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application. + +ENGINE_PATH = File.expand_path('../..', __FILE__) +load File.expand_path('../../test/dummy/script/rails', __FILE__) diff --git a/test/dummy/Rakefile b/test/dummy/Rakefile new file mode 100644 index 0000000..3645852 --- /dev/null +++ b/test/dummy/Rakefile @@ -0,0 +1,7 @@ +#!/usr/bin/env rake +# Add your own tasks in files placed in lib/tasks ending in .rake, +# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake. + +require File.expand_path('../config/application', __FILE__) + +Dummy::Application.load_tasks diff --git a/test/dummy/app/assets/javascripts/application.js b/test/dummy/app/assets/javascripts/application.js new file mode 100644 index 0000000..37c7bfc --- /dev/null +++ b/test/dummy/app/assets/javascripts/application.js @@ -0,0 +1,9 @@ +// This is a manifest file that'll be compiled into including all the files listed below. +// Add new JavaScript/Coffee code in separate files in this directory and they'll automatically +// be included in the compiled file accessible from http://example.com/assets/application.js +// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the +// the compiled file. +// +//= require jquery +//= require jquery_ujs +//= require_tree . diff --git a/test/dummy/app/assets/stylesheets/application.css b/test/dummy/app/assets/stylesheets/application.css new file mode 100644 index 0000000..fc25b57 --- /dev/null +++ b/test/dummy/app/assets/stylesheets/application.css @@ -0,0 +1,7 @@ +/* + * This is a manifest file that'll automatically include all the stylesheets available in this directory + * and any sub-directories. You're free to add application-wide styles to this file and they'll appear at + * the top of the compiled file, but it's generally better to create a new file per style scope. + *= require_self + *= require_tree . +*/ \ No newline at end of file diff --git a/test/dummy/app/controllers/application_controller.rb b/test/dummy/app/controllers/application_controller.rb new file mode 100644 index 0000000..e8065d9 --- /dev/null +++ b/test/dummy/app/controllers/application_controller.rb @@ -0,0 +1,3 @@ +class ApplicationController < ActionController::Base + protect_from_forgery +end diff --git a/test/dummy/app/helpers/application_helper.rb b/test/dummy/app/helpers/application_helper.rb new file mode 100644 index 0000000..de6be79 --- /dev/null +++ b/test/dummy/app/helpers/application_helper.rb @@ -0,0 +1,2 @@ +module ApplicationHelper +end diff --git a/test/dummy/app/mailers/.gitkeep b/test/dummy/app/mailers/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/test/dummy/app/models/.gitkeep b/test/dummy/app/models/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/test/dummy/app/views/layouts/application.html.erb b/test/dummy/app/views/layouts/application.html.erb new file mode 100644 index 0000000..9a8a761 --- /dev/null +++ b/test/dummy/app/views/layouts/application.html.erb @@ -0,0 +1,14 @@ + + + + Dummy + <%= stylesheet_link_tag "application" %> + <%= javascript_include_tag "application" %> + <%= csrf_meta_tags %> + + + +<%= yield %> + + + diff --git a/test/dummy/config.ru b/test/dummy/config.ru new file mode 100644 index 0000000..1989ed8 --- /dev/null +++ b/test/dummy/config.ru @@ -0,0 +1,4 @@ +# This file is used by Rack-based servers to start the application. + +require ::File.expand_path('../config/environment', __FILE__) +run Dummy::Application diff --git a/test/dummy/config/application.rb b/test/dummy/config/application.rb new file mode 100644 index 0000000..5baea53 --- /dev/null +++ b/test/dummy/config/application.rb @@ -0,0 +1,45 @@ +require File.expand_path('../boot', __FILE__) + +require 'rails/all' + +Bundler.require +require "web_resource" + +module Dummy + class Application < Rails::Application + # Settings in config/environments/* take precedence over those specified here. + # Application configuration should go into files in config/initializers + # -- all .rb files in that directory are automatically loaded. + + # Custom directories with classes and modules you want to be autoloadable. + # config.autoload_paths += %W(#{config.root}/extras) + + # Only load the plugins named here, in the order given (default is alphabetical). + # :all can be used as a placeholder for all plugins not explicitly named. + # config.plugins = [ :exception_notification, :ssl_requirement, :all ] + + # Activate observers that should always be running. + # config.active_record.observers = :cacher, :garbage_collector, :forum_observer + + # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone. + # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC. + # config.time_zone = 'Central Time (US & Canada)' + + # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded. + # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s] + # config.i18n.default_locale = :de + + # Configure the default encoding used in templates for Ruby 1.9. + config.encoding = "utf-8" + + # Configure sensitive parameters which will be filtered from the log file. + config.filter_parameters += [:password] + + # Enable the asset pipeline + config.assets.enabled = true + + # Version of your assets, change this if you want to expire all your assets + config.assets.version = '1.0' + end +end + diff --git a/test/dummy/config/boot.rb b/test/dummy/config/boot.rb new file mode 100644 index 0000000..eba0681 --- /dev/null +++ b/test/dummy/config/boot.rb @@ -0,0 +1,10 @@ +require 'rubygems' +gemfile = File.expand_path('../../../../Gemfile', __FILE__) + +if File.exist?(gemfile) + ENV['BUNDLE_GEMFILE'] = gemfile + require 'bundler' + Bundler.setup +end + +$:.unshift File.expand_path('../../../../lib', __FILE__) \ No newline at end of file diff --git a/test/dummy/config/database.yml b/test/dummy/config/database.yml new file mode 100644 index 0000000..51a4dd4 --- /dev/null +++ b/test/dummy/config/database.yml @@ -0,0 +1,25 @@ +# SQLite version 3.x +# gem install sqlite3 +# +# Ensure the SQLite 3 gem is defined in your Gemfile +# gem 'sqlite3' +development: + adapter: sqlite3 + database: db/development.sqlite3 + pool: 5 + timeout: 5000 + +# Warning: The database defined as "test" will be erased and +# re-generated from your development database when you run "rake". +# Do not set this db to the same as development or production. +test: + adapter: sqlite3 + database: db/test.sqlite3 + pool: 5 + timeout: 5000 + +production: + adapter: sqlite3 + database: db/production.sqlite3 + pool: 5 + timeout: 5000 diff --git a/test/dummy/config/environment.rb b/test/dummy/config/environment.rb new file mode 100644 index 0000000..3da5eb9 --- /dev/null +++ b/test/dummy/config/environment.rb @@ -0,0 +1,5 @@ +# Load the rails application +require File.expand_path('../application', __FILE__) + +# Initialize the rails application +Dummy::Application.initialize! diff --git a/test/dummy/config/environments/development.rb b/test/dummy/config/environments/development.rb new file mode 100644 index 0000000..95a50b9 --- /dev/null +++ b/test/dummy/config/environments/development.rb @@ -0,0 +1,30 @@ +Dummy::Application.configure do + # Settings specified here will take precedence over those in config/application.rb + + # In the development environment your application's code is reloaded on + # every request. This slows down response time but is perfect for development + # since you don't have to restart the web server when you make code changes. + config.cache_classes = false + + # Log error messages when you accidentally call methods on nil. + config.whiny_nils = true + + # Show full error reports and disable caching + config.consider_all_requests_local = true + config.action_controller.perform_caching = false + + # Don't care if the mailer can't send + config.action_mailer.raise_delivery_errors = false + + # Print deprecation notices to the Rails logger + config.active_support.deprecation = :log + + # Only use best-standards-support built into browsers + config.action_dispatch.best_standards_support = :builtin + + # Do not compress assets + config.assets.compress = false + + # Expands the lines which load the assets + config.assets.debug = true +end diff --git a/test/dummy/config/environments/production.rb b/test/dummy/config/environments/production.rb new file mode 100644 index 0000000..ca2c588 --- /dev/null +++ b/test/dummy/config/environments/production.rb @@ -0,0 +1,60 @@ +Dummy::Application.configure do + # Settings specified here will take precedence over those in config/application.rb + + # Code is not reloaded between requests + config.cache_classes = true + + # Full error reports are disabled and caching is turned on + config.consider_all_requests_local = false + config.action_controller.perform_caching = true + + # Disable Rails's static asset server (Apache or nginx will already do this) + config.serve_static_assets = false + + # Compress JavaScripts and CSS + config.assets.compress = true + + # Don't fallback to assets pipeline if a precompiled asset is missed + config.assets.compile = false + + # Generate digests for assets URLs + config.assets.digest = true + + # Defaults to Rails.root.join("public/assets") + # config.assets.manifest = YOUR_PATH + + # Specifies the header that your server uses for sending files + # config.action_dispatch.x_sendfile_header = "X-Sendfile" # for apache + # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for nginx + + # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies. + # config.force_ssl = true + + # See everything in the log (default is :info) + # config.log_level = :debug + + # Use a different logger for distributed setups + # config.logger = SyslogLogger.new + + # Use a different cache store in production + # config.cache_store = :mem_cache_store + + # Enable serving of images, stylesheets, and JavaScripts from an asset server + # config.action_controller.asset_host = "http://assets.example.com" + + # Precompile additional assets (application.js, application.css, and all non-JS/CSS are already added) + # config.assets.precompile += %w( search.js ) + + # Disable delivery errors, bad email addresses will be ignored + # config.action_mailer.raise_delivery_errors = false + + # Enable threaded mode + # config.threadsafe! + + # Enable locale fallbacks for I18n (makes lookups for any locale fall back to + # the I18n.default_locale when a translation can not be found) + config.i18n.fallbacks = true + + # Send deprecation notices to registered listeners + config.active_support.deprecation = :notify +end diff --git a/test/dummy/config/environments/test.rb b/test/dummy/config/environments/test.rb new file mode 100644 index 0000000..6810c91 --- /dev/null +++ b/test/dummy/config/environments/test.rb @@ -0,0 +1,39 @@ +Dummy::Application.configure do + # Settings specified here will take precedence over those in config/application.rb + + # The test environment is used exclusively to run your application's + # test suite. You never need to work with it otherwise. Remember that + # your test database is "scratch space" for the test suite and is wiped + # and recreated between test runs. Don't rely on the data there! + config.cache_classes = true + + # Configure static asset server for tests with Cache-Control for performance + config.serve_static_assets = true + config.static_cache_control = "public, max-age=3600" + + # Log error messages when you accidentally call methods on nil + config.whiny_nils = true + + # Show full error reports and disable caching + config.consider_all_requests_local = true + config.action_controller.perform_caching = false + + # Raise exceptions instead of rendering exception templates + config.action_dispatch.show_exceptions = false + + # Disable request forgery protection in test environment + config.action_controller.allow_forgery_protection = false + + # Tell Action Mailer not to deliver emails to the real world. + # The :test delivery method accumulates sent emails in the + # ActionMailer::Base.deliveries array. + config.action_mailer.delivery_method = :test + + # Use SQL instead of Active Record's schema dumper when creating the test database. + # This is necessary if your schema can't be completely dumped by the schema dumper, + # like if you have constraints or database-specific column types + # config.active_record.schema_format = :sql + + # Print deprecation notices to the stderr + config.active_support.deprecation = :stderr +end diff --git a/test/dummy/config/initializers/backtrace_silencers.rb b/test/dummy/config/initializers/backtrace_silencers.rb new file mode 100644 index 0000000..59385cd --- /dev/null +++ b/test/dummy/config/initializers/backtrace_silencers.rb @@ -0,0 +1,7 @@ +# Be sure to restart your server when you modify this file. + +# You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces. +# Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ } + +# You can also remove all the silencers if you're trying to debug a problem that might stem from framework code. +# Rails.backtrace_cleaner.remove_silencers! diff --git a/test/dummy/config/initializers/inflections.rb b/test/dummy/config/initializers/inflections.rb new file mode 100644 index 0000000..9e8b013 --- /dev/null +++ b/test/dummy/config/initializers/inflections.rb @@ -0,0 +1,10 @@ +# Be sure to restart your server when you modify this file. + +# Add new inflection rules using the following format +# (all these examples are active by default): +# ActiveSupport::Inflector.inflections do |inflect| +# inflect.plural /^(ox)$/i, '\1en' +# inflect.singular /^(ox)en/i, '\1' +# inflect.irregular 'person', 'people' +# inflect.uncountable %w( fish sheep ) +# end diff --git a/test/dummy/config/initializers/mime_types.rb b/test/dummy/config/initializers/mime_types.rb new file mode 100644 index 0000000..72aca7e --- /dev/null +++ b/test/dummy/config/initializers/mime_types.rb @@ -0,0 +1,5 @@ +# Be sure to restart your server when you modify this file. + +# Add new mime types for use in respond_to blocks: +# Mime::Type.register "text/richtext", :rtf +# Mime::Type.register_alias "text/html", :iphone diff --git a/test/dummy/config/initializers/secret_token.rb b/test/dummy/config/initializers/secret_token.rb new file mode 100644 index 0000000..5e47873 --- /dev/null +++ b/test/dummy/config/initializers/secret_token.rb @@ -0,0 +1,7 @@ +# Be sure to restart your server when you modify this file. + +# Your secret key for verifying the integrity of signed cookies. +# If you change this key, all old signed cookies will become invalid! +# Make sure the secret is at least 30 characters and all random, +# no regular words or you'll be exposed to dictionary attacks. +Dummy::Application.config.secret_token = 'ee68f8d3b8adc3f8bf4c227ae7db968e1d07dd6e6c8ea0f5deb0e55d8e19ba22fb5be6fd77ec4bffb8e78f60cd667a37d906090e8a1b03ab06bf11bb5e1b24ad' diff --git a/test/dummy/config/initializers/session_store.rb b/test/dummy/config/initializers/session_store.rb new file mode 100644 index 0000000..952473f --- /dev/null +++ b/test/dummy/config/initializers/session_store.rb @@ -0,0 +1,8 @@ +# Be sure to restart your server when you modify this file. + +Dummy::Application.config.session_store :cookie_store, key: '_dummy_session' + +# Use the database for sessions instead of the cookie-based default, +# which shouldn't be used to store highly confidential information +# (create the session table with "rails generate session_migration") +# Dummy::Application.config.session_store :active_record_store diff --git a/test/dummy/config/initializers/wrap_parameters.rb b/test/dummy/config/initializers/wrap_parameters.rb new file mode 100644 index 0000000..999df20 --- /dev/null +++ b/test/dummy/config/initializers/wrap_parameters.rb @@ -0,0 +1,14 @@ +# Be sure to restart your server when you modify this file. +# +# This file contains settings for ActionController::ParamsWrapper which +# is enabled by default. + +# Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array. +ActiveSupport.on_load(:action_controller) do + wrap_parameters format: [:json] +end + +# Disable root element in JSON by default. +ActiveSupport.on_load(:active_record) do + self.include_root_in_json = false +end diff --git a/test/dummy/config/locales/en.yml b/test/dummy/config/locales/en.yml new file mode 100644 index 0000000..179c14c --- /dev/null +++ b/test/dummy/config/locales/en.yml @@ -0,0 +1,5 @@ +# Sample localization file for English. Add more files in this directory for other locales. +# See https://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale for starting points. + +en: + hello: "Hello world" diff --git a/test/dummy/config/routes.rb b/test/dummy/config/routes.rb new file mode 100644 index 0000000..bb509f2 --- /dev/null +++ b/test/dummy/config/routes.rb @@ -0,0 +1,58 @@ +Dummy::Application.routes.draw do + # The priority is based upon order of creation: + # first created -> highest priority. + + # Sample of regular route: + # match 'products/:id' => 'catalog#view' + # Keep in mind you can assign values other than :controller and :action + + # Sample of named route: + # match 'products/:id/purchase' => 'catalog#purchase', :as => :purchase + # This route can be invoked with purchase_url(:id => product.id) + + # Sample resource route (maps HTTP verbs to controller actions automatically): + # resources :products + + # Sample resource route with options: + # resources :products do + # member do + # get 'short' + # post 'toggle' + # end + # + # collection do + # get 'sold' + # end + # end + + # Sample resource route with sub-resources: + # resources :products do + # resources :comments, :sales + # resource :seller + # end + + # Sample resource route with more complex sub-resources + # resources :products do + # resources :comments + # resources :sales do + # get 'recent', :on => :collection + # end + # end + + # Sample resource route within a namespace: + # namespace :admin do + # # Directs /admin/products/* to Admin::ProductsController + # # (app/controllers/admin/products_controller.rb) + # resources :products + # end + + # You can have the root of your site routed with "root" + # just remember to delete public/index.html. + # root :to => 'welcome#index' + + # See how all your routes lay out with "rake routes" + + # This is a legacy wild controller route that's not recommended for RESTful applications. + # Note: This route will make all actions in every controller accessible via GET requests. + # match ':controller(/:action(/:id(.:format)))' +end diff --git a/test/dummy/lib/assets/.gitkeep b/test/dummy/lib/assets/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/test/dummy/log/.gitkeep b/test/dummy/log/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/test/dummy/public/404.html b/test/dummy/public/404.html new file mode 100644 index 0000000..9a48320 --- /dev/null +++ b/test/dummy/public/404.html @@ -0,0 +1,26 @@ + + + + The page you were looking for doesn't exist (404) + + + + + +
+

The page you were looking for doesn't exist.

+

You may have mistyped the address or the page may have moved.

+
+ + diff --git a/test/dummy/public/422.html b/test/dummy/public/422.html new file mode 100644 index 0000000..83660ab --- /dev/null +++ b/test/dummy/public/422.html @@ -0,0 +1,26 @@ + + + + The change you wanted was rejected (422) + + + + + +
+

The change you wanted was rejected.

+

Maybe you tried to change something you didn't have access to.

+
+ + diff --git a/test/dummy/public/500.html b/test/dummy/public/500.html new file mode 100644 index 0000000..b80307f --- /dev/null +++ b/test/dummy/public/500.html @@ -0,0 +1,26 @@ + + + + We're sorry, but something went wrong (500) + + + + + +
+

We're sorry, but something went wrong.

+

We've been notified about this issue and we'll take a look at it shortly.

+
+ + diff --git a/test/dummy/public/favicon.ico b/test/dummy/public/favicon.ico new file mode 100644 index 0000000..e69de29 diff --git a/test/dummy/script/rails b/test/dummy/script/rails new file mode 100644 index 0000000..81eab02 --- /dev/null +++ b/test/dummy/script/rails @@ -0,0 +1,6 @@ +#!/usr/bin/env ruby.exe +# This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application. + +APP_PATH = File.expand_path('../../config/application', __FILE__) +require File.expand_path('../../config/boot', __FILE__) +require 'rails/commands' diff --git a/test/integration/navigation_test.rb b/test/integration/navigation_test.rb new file mode 100644 index 0000000..97a94c9 --- /dev/null +++ b/test/integration/navigation_test.rb @@ -0,0 +1,10 @@ +require 'test_helper' + +class NavigationTest < ActionDispatch::IntegrationTest + fixtures :all + + # test "the truth" do + # assert true + # end +end + diff --git a/test/test_helper.rb b/test/test_helper.rb new file mode 100644 index 0000000..dcd3b27 --- /dev/null +++ b/test/test_helper.rb @@ -0,0 +1,10 @@ +# Configure Rails Environment +ENV["RAILS_ENV"] = "test" + +require File.expand_path("../dummy/config/environment.rb", __FILE__) +require "rails/test_help" + +Rails.backtrace_cleaner.remove_silencers! + +# Load support files +Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f } diff --git a/test/web_resource_test.rb b/test/web_resource_test.rb new file mode 100644 index 0000000..638a499 --- /dev/null +++ b/test/web_resource_test.rb @@ -0,0 +1,7 @@ +require 'test_helper' + +class WebResourceTest < ActiveSupport::TestCase + test "truth" do + assert_kind_of Module, WebResource + end +end diff --git a/web_resource.gemspec b/web_resource.gemspec new file mode 100644 index 0000000..60a1ed5 --- /dev/null +++ b/web_resource.gemspec @@ -0,0 +1,23 @@ +$:.push File.expand_path("../lib", __FILE__) + +# Maintain your gem's version: +require "web_resource/version" + +# Describe your gem and declare its dependencies: +Gem::Specification.new do |s| + s.name = "web_resource" + s.version = WebResource::VERSION + s.authors = ["RulingDigital"] + s.email = ["service@rulingcom.com"] + s.homepage = "http://www.rulingcom.com" + s.summary = "" + s.description = "Orbit WebResource module" + + s.files = Dir["{app,config,db,lib}/**/*"] + ["MIT-LICENSE", "Rakefile", "README.rdoc"] + s.test_files = Dir["test/**/*"] + + # s.add_dependency "rails", "~> 3.1.3" + # s.add_dependency "jquery-rails" + + s.add_development_dependency "sqlite3" +end diff --git a/web_resource.json b/web_resource.json new file mode 100644 index 0000000..e053f49 --- /dev/null +++ b/web_resource.json @@ -0,0 +1,12 @@ +{ + "title": "web_resource", + "version": "0.1", + "organization": "Rulingcom", + "author": "RD dep", + "intro": "A simple blog……", + "update_info": "Some info", + "create_date": "11-11-2011", + "widgets": ["home_list"], + "category": ["WebLinkCategory"], + "enable_frontend": true +}