diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb
index e4e94c12..412da0e2 100644
--- a/app/controllers/application_controller.rb
+++ b/app/controllers/application_controller.rb
@@ -43,9 +43,9 @@ class ApplicationController < ActionController::Base
end
# Render the page
- def render_page(url = nil)
+ def render_page(id = nil)
if @item
- render :text => parse_page(@item,url)
+ render :text => parse_page(@item, id)
else
render :text => '404 Not Found'
end
diff --git a/app/controllers/pages_controller.rb b/app/controllers/pages_controller.rb
index 33c927ac..a25cb427 100644
--- a/app/controllers/pages_controller.rb
+++ b/app/controllers/pages_controller.rb
@@ -1,5 +1,7 @@
class PagesController < ApplicationController
+ before_filter :get_item, :only => [:index_from_link, :show_from_link]
+
def index
@item = Page.find_by_name('home')
if @item
@@ -9,22 +11,13 @@ class PagesController < ApplicationController
end
end
- def appfront
-
- pre_uri = URI.split request.env['HTTP_REFERER']
- pre_item_fullname = pre_uri[5][1..-1]
- @item = Item.first(:conditions => {:full_name => pre_item_fullname})
- redirect_to (request.env['HTTP_REFERER'].partition("?")[0]+"?app_url=#{request.fullpath}")
-
- end
-
def show
#begin
item = Item.first(:conditions => {:full_name => params[:page_name]})
case item._type
when 'Page'
@item = item
- render_page ((params[:app_url]+'?inner='+"true" if params[:app_url]))
+ render_page(params[:id])
when 'Link'
redirect_to "http://#{item[:url]}"
end
@@ -32,5 +25,20 @@ class PagesController < ApplicationController
# render :file => "#{Rails.root}/public/404.html", :status => :not_found
#end
end
+
+ def index_from_link
+ redirect_to "/#{@item.full_name}"
+ end
+
+ def show_from_link
+ redirect_to "/#{@item.full_name}?id=#{params[:id]}"
+ end
+
+ protected
+
+ def get_item
+ module_app = ModuleApp.first(:conditions => {:title => params[:app_name]})
+ @item = Item.first(:conditions => {:module_app_id => module_app.id, :app_frontend_url => params[:app_action]})
+ end
end
diff --git a/config/routes.rb b/config/routes.rb
index efa64576..60f87467 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -77,10 +77,14 @@ PrototypeR4::Application.routes.draw do
namespace :panel do
resources :users
end
-
- match '/panel/:app_name/front_end/*page_name' => 'pages#appfront', :via => "get",:constraints => lambda { |request|
+
+ match '/panel/:app_name/front_end/:app_action/:id' => 'pages#show_from_link', :constraints => lambda { |request|
!request.query_string.include?("inner=true")
- }
+ }
+
+ match '/panel/:app_name/front_end/:app_action' => 'pages#index_from_link', :constraints => lambda { |request|
+ !request.query_string.include?("inner=true")
+ }
# routes for gridfs files
match "/gridfs/*path" => "gridfs#serve"
diff --git a/lib/parsers/parser_back_end.rb b/lib/parsers/parser_back_end.rb
index 48b6a1df..3960d2cd 100644
--- a/lib/parsers/parser_back_end.rb
+++ b/lib/parsers/parser_back_end.rb
@@ -84,7 +84,7 @@ module ParserBackEnd
c.define_tag 'content' do |tag|
ret = ''
if (tag.attributes["main"] == "true" && !page.module_app.nil?)
- ret << "
"
+ ret << ""
else
part = page.page_parts.detect{ |p| p.name.to_s == tag.attr['name'].to_s }
ret << ""
diff --git a/lib/parsers/parser_front_end.rb b/lib/parsers/parser_front_end.rb
index 3452f4fc..d36bf654 100644
--- a/lib/parsers/parser_front_end.rb
+++ b/lib/parsers/parser_front_end.rb
@@ -2,7 +2,7 @@ module ParserFrontEnd
require 'radius'
include ParserCommon
- def parser_context(page, attributes = {},appfront_url = nil)
+ def parser_context(page, attributes = {}, id = nil)
Radius::Context.new do |c|
c.define_tag 'snippet' do |tag|
snippet = Snippet.first(:conditions => {:name => tag.attr['name']})
@@ -101,7 +101,9 @@ module ParserFrontEnd
c.define_tag 'content' do |tag|
ret = ''
if (tag.attributes["main"] == "true" && !page.module_app.nil?)
- ret << "
"
+ ret << "
"
else
part = page.page_parts.detect{ |p| p.name.to_s == tag.attr['name'].to_s } rescue nil
ret << part.content rescue nil
@@ -123,10 +125,10 @@ module ParserFrontEnd
end
end
- def parse_page(page ,appfront_url)
+ def parse_page(page, id = nil)
if page._type == 'Page'
layout_content = page.design.layout.content.force_encoding('UTF-8') rescue ''
- context = parser_context(page,{}, appfront_url)
+ context = parser_context(page, {}, id)
parser = Radius::Parser.new(context, :tag_prefix => 'r')
parser.parse(parser.parse(layout_content))
end
diff --git a/vendor/built_in_modules/new_blog/app/assets/images/NewBlog/.gitkeep b/vendor/built_in_modules/new_blog/app/assets/images/new_blog/.gitkeep
similarity index 100%
rename from vendor/built_in_modules/new_blog/app/assets/images/NewBlog/.gitkeep
rename to vendor/built_in_modules/new_blog/app/assets/images/new_blog/.gitkeep
diff --git a/vendor/built_in_modules/new_blog/app/assets/javascripts/NewBlog/.gitkeep b/vendor/built_in_modules/new_blog/app/assets/javascripts/new_blog/.gitkeep
similarity index 100%
rename from vendor/built_in_modules/new_blog/app/assets/javascripts/NewBlog/.gitkeep
rename to vendor/built_in_modules/new_blog/app/assets/javascripts/new_blog/.gitkeep
diff --git a/vendor/built_in_modules/new_blog/app/assets/stylesheets/NewBlog/.gitkeep b/vendor/built_in_modules/new_blog/app/assets/stylesheets/new_blog/.gitkeep
similarity index 100%
rename from vendor/built_in_modules/new_blog/app/assets/stylesheets/NewBlog/.gitkeep
rename to vendor/built_in_modules/new_blog/app/assets/stylesheets/new_blog/.gitkeep
diff --git a/vendor/built_in_modules/new_blog/app/assets/stylesheets/NewBlog/application.css b/vendor/built_in_modules/new_blog/app/assets/stylesheets/new_blog/application.css
similarity index 100%
rename from vendor/built_in_modules/new_blog/app/assets/stylesheets/NewBlog/application.css
rename to vendor/built_in_modules/new_blog/app/assets/stylesheets/new_blog/application.css
diff --git a/vendor/built_in_modules/new_blog/app/assets/stylesheets/NewBlog/production.css b/vendor/built_in_modules/new_blog/app/assets/stylesheets/new_blog/production.css
similarity index 100%
rename from vendor/built_in_modules/new_blog/app/assets/stylesheets/NewBlog/production.css
rename to vendor/built_in_modules/new_blog/app/assets/stylesheets/new_blog/production.css
diff --git a/vendor/built_in_modules/new_blog/config/routes.rb b/vendor/built_in_modules/new_blog/config/routes.rb
index c5b65a18..860d50a6 100644
--- a/vendor/built_in_modules/new_blog/config/routes.rb
+++ b/vendor/built_in_modules/new_blog/config/routes.rb
@@ -9,8 +9,8 @@ Rails.application.routes.draw do
end
namespace :front_end do
root :to => "posts#index"
- match "show/:id" => "posts#show" ,:as => :post
- match "comments" => "comments#create",:as => :comments
+ resources :posts
+ resources :comments
end
namespace :widget do
root :to => "posts#index"
diff --git a/vendor/built_in_modules/new_blog/new_blog.json b/vendor/built_in_modules/new_blog/new_blog.json
index ec18ee08..480f7efa 100755
--- a/vendor/built_in_modules/new_blog/new_blog.json
+++ b/vendor/built_in_modules/new_blog/new_blog.json
@@ -1,12 +1,12 @@
{
- "title": "NewBlog",
+ "title": "new_blog",
"version": "0.1",
"organization": "Rulingcom",
"author": "RD dep",
"intro": "A simple blog……",
"update_info": "Some info",
"create_date": "11-11-2011",
- "app_pages": ["/panel/new_blog/front_end/"],
- "widgets": ["/panel/new_blog/widget/latest_post","/panel/new_blog/widget/"],
- "enable_frontend": false
+ "app_pages": ["posts"],
+ "widgets": ["/latest_post","/"],
+ "enable_frontend": true
}