From 93cba6bad7b268a3295c64a9c3751ff66e5356f9 Mon Sep 17 00:00:00 2001 From: Saurabh Bhatia Date: Wed, 2 Jul 2014 17:01:14 +0800 Subject: [PATCH] added index and show frontend page fixes in engine --- app/controllers/journal_papers_controller.rb | 43 +++++++++++++++++++ app/views/journal_papers/index.html.erb | 1 + app/views/journal_papers/show.html.erb | 1 + config/routes.rb | 2 + lib/personal_journal/engine.rb | 9 ++-- .../journal_papers_controller_test.rb | 4 +- 6 files changed, 54 insertions(+), 6 deletions(-) create mode 100644 app/controllers/journal_papers_controller.rb create mode 100644 app/views/journal_papers/index.html.erb create mode 100644 app/views/journal_papers/show.html.erb diff --git a/app/controllers/journal_papers_controller.rb b/app/controllers/journal_papers_controller.rb new file mode 100644 index 0000000..3f49e5d --- /dev/null +++ b/app/controllers/journal_papers_controller.rb @@ -0,0 +1,43 @@ +class JournalPapersController < ApplicationController + def index + journal_papers = JournalPaper.asc(:created_at) + journal_paper_list = journal_papers.collect do |journal_paper| + { + "paper_title" => journal_paper.paper_title, + "authors" => journal_paper.authors, + "link_to_show" => OrbitHelper.url_to_show(journal_paper.to_param) + } + end + { + "journal_papers" => journal_paper_list, + "extras" => {"widget-title" => "Journal Papers"} + } + end + + def show + params = OrbitHelper.params + journal_paper = JournalPaper.find_by(uid: params[:uid]) + files = journal_paper.journal_paper_files.map{|file| { "file_url" => file.journal_file.url, "file_title" => (file.title.blank? ? File.basename(file.file.path) : file.title) } } rescue [] + { + "journal_paper_files" => files, + "data" => { + "title" => journal_paper.paper_title, + "journal_title" => journal_paper.journal_title, + "year" => journal_paper.year, + "authors" => journal_paper.authors, + "isbn" => journal_paper.isbn, + "vol_no" => journal_paper.vol_no, + "issue_no" => journal_paper.issue_no, + "form_to_start" => journal_paper.form_to_start, + "form_to_end" => journal_paper.form_to_end, + "language" => t(journal_paper.language), + "total_pages" => journal_paper.total_pages, + "keywords" => journal_paper.keywords, + "abstract" => journal_paper.abstract, + "publication_date" => journal_paper.publication_date.to_date.strftime("%Y/%m/%d"), + "url" => journal_paper.url, + "note" => journal_paper.note + } + } + end +end diff --git a/app/views/journal_papers/index.html.erb b/app/views/journal_papers/index.html.erb new file mode 100644 index 0000000..832b54c --- /dev/null +++ b/app/views/journal_papers/index.html.erb @@ -0,0 +1 @@ +<%= render_view%> \ No newline at end of file diff --git a/app/views/journal_papers/show.html.erb b/app/views/journal_papers/show.html.erb new file mode 100644 index 0000000..648b75c --- /dev/null +++ b/app/views/journal_papers/show.html.erb @@ -0,0 +1 @@ +<%= render_view %> \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index 9831d7d..7fde0f8 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,5 +1,7 @@ Rails.application.routes.draw do + # get 'journal_papers/index' + locales = Site.find_by(site_active: true).in_use_locales rescue I18n.available_locales scope "(:locale)", locale: Regexp.new(locales.join("|")) do namespace :admin do diff --git a/lib/personal_journal/engine.rb b/lib/personal_journal/engine.rb index 18f8e67..0eca3c0 100644 --- a/lib/personal_journal/engine.rb +++ b/lib/personal_journal/engine.rb @@ -1,17 +1,18 @@ module PersonalJournal class Engine < ::Rails::Engine - initializer "personal_journal" do - OrbitApp.registration "PersonalJournal",:type=> 'ModuleApp' do + initializer "journal_paper" do + OrbitApp.registration "JournalPaper",:type=> 'ModuleApp' do module_label 'module_name.journal_paper' base_url File.expand_path File.dirname(__FILE__) - personal_plugin :enable => true, :sort_number => '5', :app_name=>"JournalPaper", :intro_app_name=>"JournalPaperlIntro",:path=>"/plugin/journal_paper/profile",:front_path=>"/profile",:admin_path=>"/admin/journal_papers/",:i18n=>'module_name.journal_paper' + personal_plugin :enable => true, :sort_number => '5', :app_name=>"JournalPaper", :intro_app_name=>"JournalPaperlIntro",:path=>"/plugin/journal_paper/profile",:front_path=>"/profile",:admin_path=>"/admin/journal_papers/",:i18n=>'module_name.journal_paper', :module_app_name=>'JournalPaper' version "0.1" organization "Rulingcom" author "RD dep" intro "I am intro" update_info 'some update_info' - + frontend_enabled + icon_class_no_sidebar "icons-user" end end end diff --git a/test/controllers/journal_papers_controller_test.rb b/test/controllers/journal_papers_controller_test.rb index adcc6db..9eda987 100644 --- a/test/controllers/journal_papers_controller_test.rb +++ b/test/controllers/journal_papers_controller_test.rb @@ -1,8 +1,8 @@ require 'test_helper' class JournalPapersControllerTest < ActionController::TestCase - test "should get show" do - get :show + test "should get index" do + get :index assert_response :success end