Change NewBlog to new_blog

This commit is contained in:
Matthew Fu 2012-01-10 18:29:11 +08:00
parent 79f778ad8c
commit cae3daa9c4
96 changed files with 133 additions and 65 deletions

View File

@ -28,7 +28,7 @@ class Admin::PagePartsController < ApplicationController
@partial = 'edit_text'
@part_locale = params[:part_locale] || I18n.locale.to_s
when 'module'
@plugins=[{:module=>"Blog",:widgets=>[{:name=>"Blog",:path=>"panel/blog/widget_latest_post"},{:name=>"Blog",:path=>"panel/blog/widget_index"}]}]
@plugins=[{:module=>"Blog",:widgets=>[{:name=>"Blog",:path=>"panel/new_blog/widget_latest_post"},{:name=>"Blog",:path=>"panel/new_blog/widget_index"}]}]
when 'snippet'
end
end

View File

@ -9,12 +9,12 @@ class ApplicationController < ActionController::Base
def front_end_available(module_app_title='')
app_controller = ModuleApp.first(conditions: {:title => module_app_title} )
unless app_controller.enable_frontend?
render :text => 'View not available'
render :nothing
end
end
def get_all_app_engines
ary = ["vender/plugins/NewBlog"]
ary = ["vender/plugins/new_blog"]
app_engines = ary.collect{|t|
Rails::Engine.find t
}

View File

@ -0,0 +1,4 @@
class ObitFrontendComponentController< ApplicationController
before_filter {|c| c.front_end_available(@app_title)}
layout 'production'
end

View File

@ -0,0 +1,3 @@
class ObitFrontendController< ObitFrontendComponentController
end

View File

@ -0,0 +1,3 @@
class ObitWidgetController< ObitFrontendComponentController
end

Binary file not shown.

View File

@ -26,8 +26,8 @@
<div id="main_content" class="content">
<r:content name='content_1' main='true'>
</r:content>
<div class="dymanic_load" path="/panel/blog/widget/latest_post"></div>
<div class="dymanic_load" path="/panel/blog/widget/"></div>
<div class="dymanic_load" path="/panel/new_blog/widget/latest_post"></div>
<div class="dymanic_load" path="/panel/new_blog/widget/"></div>
</div>
<div id="footer" class="footer">

View File

@ -118,7 +118,7 @@ namespace :dev do
home = Page.create!( :i18n_variable_id => var_10.id, :design_id => design_1.id, :name => 'home', :is_published => true, :theme_id => theme.id )
home.page_parts.create!( :name => 'content_1', :content => File.open("#{Rails.root}/lib/template/home.page").read, :kind => 'text', :i18n_variable_id => var_13.id )
ModuleApp.create.from_json(File.open("#{Rails.root}/vendor/built_in_modules/NewBlog/NewBlog.json").read).save
ModuleApp.create.from_json(File.open("#{Rails.root}/vendor/built_in_modules/new_blog/new_blog.json").read).save
Post.create(:title=>"1st post",:body=>"Long long time ago.....")
Post.create(:title=>"2ec post",:body=>"And?.....")

View File

@ -1,8 +0,0 @@
<h1><%= t('blog.editing_post') %></h1>
<%= form_for @post, :url => panel_blog_back_end_post_path(@post) do |f| %>
<%= render :partial => 'form', :locals => {:f => f} %>
<% end %>
<%= link_to t('blog.show'), panel_blog_back_end_post_path(@post) %> |
<%= link_back %>

View File

@ -1,5 +0,0 @@
require "NewBlog/engine"
module NewBlog
end

View File

@ -1,25 +0,0 @@
<h1><%= t('blog.list_post') %></h1>
<table>
<tr>
<th><%= t('blog.title') %></th>
<th><%= t('blog.body') %></th>
<th></th>
<th></th>
<th></th>
</tr>
<% @posts.each do |post| %>
<tr>
<td><%= post.title %></td>
<td><%= post.body %></td>
<td><%= link_to t('blog.show'), panel_blog_post_path(post) %></td>
<td><%= link_to t('blog.edit'), edit_panel_blog_post_path(post) %></td>
<td><%= link_to t('blog.delete'), panel_blog_post_path(post), :confirm => t('blog.sure?'), :method => :delete %></td>
</tr>
<% end %>
</table>
<br />
<%= link_to t('blog.new_post'), new_panel_blog_back_end_post_path %>

View File

@ -1,4 +1,4 @@
class Panel::Blog::BackEnd::PostsController < ApplicationController
class Panel::NewBlog::BackEnd::PostsController < ApplicationController
layout 'admin'
@ -45,7 +45,7 @@ class Panel::Blog::BackEnd::PostsController < ApplicationController
respond_to do |format|
if @post.save
format.html { redirect_to(panel_blog_post_url(@post), :notice => t('blog.create_post_success')) }
format.html { redirect_to(panel_new_blog_post_url(@post), :notice => t('blog.create_post_success')) }
format.xml { render :xml => @post, :status => :created, :location => @post }
else
format.html { render :action => "new" }
@ -61,7 +61,7 @@ class Panel::Blog::BackEnd::PostsController < ApplicationController
respond_to do |format|
if @post.update_attributes(params[:post])
format.html { redirect_to(panel_blog_post_url(@post), :notice => t('blog.update_post_success')) }
format.html { redirect_to(panel_new_blog_post_url(@post), :notice => t('blog.update_post_success')) }
format.xml { head :ok }
else
format.html { render :action => "edit" }
@ -77,7 +77,7 @@ class Panel::Blog::BackEnd::PostsController < ApplicationController
@post.destroy
respond_to do |format|
format.html { redirect_to(panel_blog_posts_url) }
format.html { redirect_to(panel_new_blog_posts_url) }
format.xml { head :ok }
end
end

View File

@ -0,0 +1,7 @@
class Panel::NewBlog::FrontEnd::CommentsController < ObitFrontendController
def create
@post = Post.find(params[:post_id])
@comment = @post.comments.create!(params[:comment])
redirect_to panel_new_blog_front_end_post_url(@post)
end
end

View File

@ -0,0 +1,21 @@
class Panel::NewBlog::FrontEnd::PostsController < ObitFrontendController
def initialize
super
@app_title = NewBlog::MOUDLEAPP_TITLE
end
# GET /posts
# GET /posts.xml
def index
@posts = Post.all
end
def show
@post = Post.find(params[:id])
end
end

View File

@ -1,4 +1,4 @@
class Panel::Blog::Widget::PostsController < ObitWidgetController
class Panel::NewBlog::Widget::PostsController < ObitWidgetController
layout 'production'

View File

@ -0,0 +1,8 @@
<h1><%= t('blog.editing_post') %></h1>
<%= form_for @post, :url => panel_new_blog_back_end_post_path(@post) do |f| %>
<%= render :partial => 'form', :locals => {:f => f} %>
<% end %>
<%= link_to t('blog.show'), panel_new_blog_back_end_post_path(@post) %> |
<%= link_back %>

View File

@ -1,6 +1,6 @@
<% content_for :secondary do %>
<ul class="list">
<li><%= link_to t('blog.new_post'), new_panel_blog_back_end_post_path, :class => 'seclink1' %></li>
<li><%= link_to t('blog.new_post'), new_panel_new_blog_back_end_post_path, :class => 'seclink1' %></li>
</ul>
<% end -%>
@ -21,9 +21,9 @@
<tr>
<td><%= post.title %></td>
<td><%= truncate(post.body,:length=>15) %></td>
<td><%= link_to t('blog.show'), panel_blog_back_end_post_path(post) %></td>
<td><%= link_to t('blog.edit'), edit_panel_blog_back_end_post_path(post) %></td>
<td><%= link_to t('blog.delete'), panel_blog_back_end_post_path(post), :confirm => t('blog.sure?'), :method => :delete %></td>
<td><%= link_to t('blog.show'), panel_new_blog_back_end_post_path(post) %></td>
<td><%= link_to t('blog.edit'), edit_panel_new_blog_back_end_post_path(post) %></td>
<td><%= link_to t('blog.delete'), panel_new_blog_back_end_post_path(post), :confirm => t('blog.sure?'), :method => :delete %></td>
</tr>
<% end %>
</table>

View File

@ -1,4 +1,4 @@
<%=stylesheet_link_tag "NewBlog/application"%>
<%=stylesheet_link_tag "new_blog/application"%>
<h2><%=@post.title%></h2>
<p>
<%= @post.body%>

View File

@ -1,12 +1,12 @@
<% content_for :secondary do %>
<ul class="list">
<li><%= link_to t('blog.index'), panel_blog_back_end_posts_path, :class => 'seclink2' %></li>
<li><%= link_to t('blog.index'), panel_new_blog_back_end_posts_path, :class => 'seclink2' %></li>
</ul>
<% end -%>
<%= flash_messages %>
<h1><%= t('blog.new_post') %></h1>
<%= form_for @post, :url => panel_blog_back_end_posts_path do |f| %>
<%= form_for @post, :url => panel_new_blog_back_end_posts_path do |f| %>
<%= render :partial => 'form', :locals => {:f => f} %>
<% end %>

View File

@ -18,7 +18,7 @@
</p>
<% end %>
<%= form_for Comment.new, :url => panel_blog_front_end_comments_path do |f| %>
<%= form_for Comment.new, :url => panel_new_blog_front_end_comments_path do |f| %>
<p>
<%= f.label :name, "Author" %><br />
@ -34,5 +34,5 @@
<% end %>
<%= link_to t('blog.edit'), edit_panel_blog_back_end_post_path(@post) %> |
<%= link_to t('blog.edit'), edit_panel_new_blog_back_end_post_path(@post) %> |
<%= link_back %>

View File

@ -2,6 +2,6 @@
<%= post_frontend.title %><br />
<p>
<%= truncate(post_frontend.body,:length=>25) %>
<%= link_to 'Read more...',panel_blog_front_end_post_path(post_frontend) %>
<%= link_to 'Read more...',panel_new_blog_front_end_post_path(post_frontend) %>
</p>
</div>

View File

@ -1,6 +1,6 @@
<% content_for :secondary do %>
<ul class="list">
<li><%= link_to t('blog.new_post'), new_panel_blog_back_end_post_path, :class => 'seclink1' %></li>
<li><%= link_to t('blog.new_post'), new_panel_new_blog_back_end_post_path, :class => 'seclink1' %></li>
</ul>
<% end -%>

View File

@ -18,7 +18,7 @@
</p>
<% end %>
<%= form_for Comment.new, :url => panel_blog_front_end_comments_path do |f| %>
<%= form_for Comment.new, :url => panel_new_blog_front_end_comments_path do |f| %>
<p>
<%= f.label :name, "Author" %><br />

View File

@ -1,4 +1,4 @@
<%=stylesheet_link_tag "NewBlog/application"%>
<%=stylesheet_link_tag "new_blog/application"%>
<div class="widget_index">
<table>
<tr>
@ -8,7 +8,7 @@
<% @posts.each do |post| %>
<tr>
<td><%= link_to post.title,panel_blog_front_end_post_path(post) %></td>
<td><%= link_to post.title,panel_new_blog_front_end_post_path(post) %></td>
<td><%= post.body.truncate(14) %></td>
</tr>
<% end %>

View File

@ -1,4 +1,4 @@
<%=stylesheet_link_tag "NewBlog/application"%>
<%=stylesheet_link_tag "new_blog/application"%>
<div class="widget_latest_post">
<h2><%= @post.title %> </h2>
<p>

View File

@ -0,0 +1,18 @@
# module NewBlog
# class MyEngine < Rails::Engine
# # Add a load path for this specific Engine
# # config.autoload_paths << File.expand_path("../lib/some/path", __FILE__)
# put "ABC"
# PrototypeR4::Application::Orbit_Apps << "NewBlog"
#
# # initializer "my_engine.add_middleware" do |app|
# # app.middleware.use MyEngine::Middleware
# # end
# end
#
# end
module NewBlog
VERSION = "0.0.1"
MOUDLEAPP_TITLE = "NewBlog"
end
# PrototypeR4::Application::Orbit_Apps << "NewBlog"

View File

@ -0,0 +1,25 @@
Rails.application.routes.draw do
namespace :panel do
namespace :new_blog do
namespace :back_end do
root :to => "posts#index"
resources :posts
resources :comments
end
namespace :front_end do
root :to => "posts#index"
match "show/:id" => "posts#show" ,:as => :post
match "comments" => "comments#create",:as => :comments
end
namespace :widget do
root :to => "posts#index"
match "latest_post" => "posts#latest_post"
end
end
end
# match "appfront/blog/front_end/show/:id" => "posts#frontend_show" ,:as => :appfront_blog_show
match "/appfront/*path" => redirect("/panel/*path")
end

View File

@ -0,0 +1,5 @@
require "new_blog/engine"
module NewBlog
end

View File

@ -1,5 +1,5 @@
module NewBlog
class Engine < Rails::Engine
isolate_namespace NewBlog
isolate_namespace new_blog
end
end

View File

@ -0,0 +1,12 @@
{
"title": "NewBlog",
"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
}