added index and show frontend page fixes in engine

This commit is contained in:
Saurabh Bhatia 2014-07-02 17:01:14 +08:00
parent a3c66b1a6e
commit 93cba6bad7
6 changed files with 54 additions and 6 deletions

View File

@ -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

View File

@ -0,0 +1 @@
<%= render_view%>

View File

@ -0,0 +1 @@
<%= render_view %>

View File

@ -1,5 +1,7 @@
Rails.application.routes.draw do Rails.application.routes.draw do
# get 'journal_papers/index'
locales = Site.find_by(site_active: true).in_use_locales rescue I18n.available_locales locales = Site.find_by(site_active: true).in_use_locales rescue I18n.available_locales
scope "(:locale)", locale: Regexp.new(locales.join("|")) do scope "(:locale)", locale: Regexp.new(locales.join("|")) do
namespace :admin do namespace :admin do

View File

@ -1,17 +1,18 @@
module PersonalJournal module PersonalJournal
class Engine < ::Rails::Engine class Engine < ::Rails::Engine
initializer "personal_journal" do initializer "journal_paper" do
OrbitApp.registration "PersonalJournal",:type=> 'ModuleApp' do OrbitApp.registration "JournalPaper",:type=> 'ModuleApp' do
module_label 'module_name.journal_paper' module_label 'module_name.journal_paper'
base_url File.expand_path File.dirname(__FILE__) 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" version "0.1"
organization "Rulingcom" organization "Rulingcom"
author "RD dep" author "RD dep"
intro "I am intro" intro "I am intro"
update_info 'some update_info' update_info 'some update_info'
frontend_enabled
icon_class_no_sidebar "icons-user"
end end
end end
end end

View File

@ -1,8 +1,8 @@
require 'test_helper' require 'test_helper'
class JournalPapersControllerTest < ActionController::TestCase class JournalPapersControllerTest < ActionController::TestCase
test "should get show" do test "should get index" do
get :show get :index
assert_response :success assert_response :success
end end