merge with november_presentation

This commit is contained in:
chris2tof 2011-12-22 15:43:38 +08:00
parent fa27bfc86b
commit d465febca7
27 changed files with 437 additions and 6 deletions

View File

View File

@ -4,7 +4,7 @@ class Admin::AppAuthsController < ApplicationController
before_filter :is_admin? before_filter :is_admin?
def index def index
@roles = Role.all.entries @user_roles = UserRole.all.entries
apps = Purchase.where(:type =>"App") apps = Purchase.where(:type =>"App")
@app_auth_data = apps.entries.map do |app| @app_auth_data = apps.entries.map do |app|
app_c = eval(app.app_controller) app_c = eval(app.app_controller)

View File

@ -24,6 +24,35 @@ class Design
after_save :procs_embedded_objects after_save :procs_embedded_objects
# after_destroy :del_embedded_objects # after_destroy :del_embedded_objects
# validate do
# errors.add('atttribute1', 'error for 1') if files_with_duplicate?
# errors.add('atttribute2', 'error for 1') if files_with_noname?
# end
def files_with_duplicate?
[self.javascripts, self.images,self.themes].each do |objects_hash|
ary = objects_hash.collect{ |k| k.file_filename}
ary.compact!
# debugger
return true if(ary.count!=ary.uniq.count)
end
false
end
def files_with_noname?
[self.javascripts, self.images,self.themes].each do |objects_hash|
objects_hash.each{ |k|
return true if(k.file_filename.nil? && !k.to_save?)
}
end
false
end
def new_files=(*attrs)
attrs[0].map do |key,items_ary| #Loop by JSs,Themes,Imgs
self.files=([items_ary, key])
end
end
def javascripts=(*attrs) def javascripts=(*attrs)
self.files = (attrs << 'javascripts') self.files = (attrs << 'javascripts')
end end
@ -45,6 +74,7 @@ class Design
files = eval(attrs.last) files = eval(attrs.last)
end end
attrs[0].each do |a| attrs[0].each do |a|
if a[:id].blank? && !a[:file].blank? if a[:id].blank? && !a[:file].blank?
files.build(:file => a[:file], :to_save => true) files.build(:file => a[:file], :to_save => true)
else else
@ -86,12 +116,14 @@ class Design
end end
end end
end end
self.valid?
end end
def process_object(object) def process_object(object)
if object.to_save if object.to_save
if object.file_filename.nil? if object.file_filename.nil?
new_object = self.send(object._type.downcase.pluralize).build(object) new_object = self.send(object._type.downcase.pluralize).build(object.attributes)
new_object.file = object.file
object.destroy object.destroy
new_object.to_save = false new_object.to_save = false
new_object.save new_object.save

View File

@ -18,7 +18,7 @@
<% end %> <% end %>
</ul> </ul>
<p class="new_file"> <p class="new_file">
<%= fields_for "design[" + field_name + "][]", object.send(field_name).build, :index => nil do |f| %> <%= fields_for "design[new_files][" + field_name + "][]", object.send(field_name).build, :index => nil do |f| %>
<%= f.file_field :file, :class => "multi_files" %> <%= f.file_field :file, :class => "multi_files" %>
</p> </p>
<% end %> <% end %>

View File

@ -1,6 +1,6 @@
<h1><%= t('admin.editing_design') %></h1> <h1><%= t('admin.editing_design') %></h1>
<%= form_for @design, :url => admin_design_path(@design) do |f| %> <%= form_for @design, :url => admin_design_path(@design),:html => {:multipart => true} do |f| %>
<%= f.error_messages %> <%= f.error_messages %>
<%= render :partial => "form", :locals => { :f => f } %> <%= render :partial => "form", :locals => { :f => f } %>
<p> <p>

View File

@ -1,6 +1,6 @@
<h1><%= t('admin.new_design') %></h1> <h1><%= t('admin.new_design') %></h1>
<%= form_for :design, :url => admin_designs_path do |f| %> <%= form_for :design, :url => admin_designs_path,:html => {:multipart => true} do |f| %>
<%= f.error_messages %> <%= f.error_messages %>
<%= render :partial => "form", :locals => { :f => f } %> <%= render :partial => "form", :locals => { :f => f } %>

View File

@ -0,0 +1,5 @@
Module.instance_eval do
def using_object_ids?
false
end
end

11
lib/tasks/app_auth.rake Normal file
View File

@ -0,0 +1,11 @@
# encoding: utf-8
namespace :app_auth do
task :build => :environment do
end
end

View File

@ -5,6 +5,7 @@ Spork.prefork do
# Loading more in this block will cause your tests to run faster. However, # Loading more in this block will cause your tests to run faster. However,
# if you change any configuration or code from libraries loaded here, you'll # if you change any configuration or code from libraries loaded here, you'll
# need to restart spork for it take effect. # need to restart spork for it take effect.
# This file is copied to spec/ when you run 'rails generate rspec:install' # This file is copied to spec/ when you run 'rails generate rspec:install'
ENV["RAILS_ENV"] ||= 'test' ENV["RAILS_ENV"] ||= 'test'
require File.expand_path("../../config/environment", __FILE__) require File.expand_path("../../config/environment", __FILE__)
@ -54,4 +55,4 @@ end
# - Any code that is left outside of the blocks will be ran during preforking # - Any code that is left outside of the blocks will be ran during preforking
# and during each_run! # and during each_run!
# - These instructions should self-destruct in 10 seconds. If they don't, # - These instructions should self-destruct in 10 seconds. If they don't,
# feel free to delete them. # feel free to delete them.

View File

@ -0,0 +1,25 @@
<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 %>

9
vendor/plugins/NewBlog/NewBlog.json vendored Executable file
View File

@ -0,0 +1,9 @@
{
"title": "NewBlog",
"version": "0.1",
"organization": "Rulingcom",
"author": "RD dep",
"intro": "A simple blog……",
"update_info": "Some info",
"create_date": "11-11-2011"
}

View File

@ -0,0 +1,84 @@
class Panel::Blog::BackEnd::PostsController < ApplicationController
layout 'admin'
def index
@posts = Post.all
respond_to do |format|
format.html # index.html.erb
format.xml { render :xml => @posts }
end
end
# GET /posts/1
# GET /posts/1.xml
def show
@post = Post.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.xml { render :xml => @post }
end
end
# GET /posts/new
# GET /posts/new.xml
def new
@post = Post.new
respond_to do |format|
format.html # new.html.erb
format.xml { render :xml => @post }
end
end
# GET /posts/1/edit
def edit
@post = Post.find(params[:id])
end
# POST /posts
# POST /posts.xml
def create
@post = Post.new(params[:post])
respond_to do |format|
if @post.save
format.html { redirect_to(panel_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" }
format.xml { render :xml => @post.errors, :status => :unprocessable_entity }
end
end
end
# PUT /posts/1
# PUT /posts/1.xml
def update
@post = Post.find(params[:id])
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.xml { head :ok }
else
format.html { render :action => "edit" }
format.xml { render :xml => @post.errors, :status => :unprocessable_entity }
end
end
end
# DELETE /posts/1
# DELETE /posts/1.xml
def destroy
@post = Post.find(params[:id])
@post.destroy
respond_to do |format|
format.html { redirect_to(panel_blog_posts_url) }
format.xml { head :ok }
end
end
end

View File

@ -0,0 +1,13 @@
<%= f.error_messages %>
<div class="field">
<%= f.label :title %><br />
<%= f.text_field :title %>
</div>
<div class="field">
<%= f.label :body %><br />
<%= f.text_area :body %>
</div>
<div class="actions">
<%= f.submit %>
</div>

View File

@ -0,0 +1,32 @@
<% content_for :secondary do %>
<ul class="list">
<li><%= link_to t('blog.new_post'), new_panel_blog_back_end_post_path, :class => 'seclink1' %></li>
</ul>
<% end -%>
<%= flash_messages %>
<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><%= 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>
</tr>
<% end %>
</table>
<br />

View File

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

View File

@ -0,0 +1,13 @@
<% content_for :secondary do %>
<ul class="list">
<li><%= link_to t('blog.index'), panel_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| %>
<%= render :partial => 'form', :locals => {:f => f} %>
<% end %>
<%= link_back %>

View File

@ -0,0 +1,34 @@
<p id="notice"><%= flash_messages %></p>
<p>
<b><%= t('blog.body') %></b>
<%=h @post.body %>
</p>
<h2><%= t('blog.comments') %></h2>
<% @post.comments.each do |c| %>
<p>
<b><%=h c.name %> said:</b><br />
<%= time_ago_in_words(c.created_at) %> ago
</p>
<p>
<%=h c.body %>
</p>
<% end %>
<%= form_for Comment.new, :url => panel_blog_front_end_comments_path do |f| %>
<p>
<%= f.label :name, "Author" %><br />
<%= f.text_field :name %><br />
<%= f.label :body, "Comment Description" %><br />
<%= f.text_area :body %>
<%= hidden_field_tag :post_id, @post.id %>
</p>
<p>
<%= f.submit "Add Comment" %>
</p>
<% end %>

View File

@ -0,0 +1,32 @@
<% content_for :secondary do %>
<ul class="list">
<li><%= link_to t('blog.new_post'), new_panel_blog_post_path, :class => 'seclink1' %></li>
</ul>
<% end -%>
<%= flash_messages %>
<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><%= truncate(post.body,:length=>15) %></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 />

View File

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

View File

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

View File

@ -0,0 +1,38 @@
<p id="notice"><%= flash_messages %></p>
<p>
<b><%= t('blog.body') %></b>
<%=h @post.body %>
</p>
<h2><%= t('blog.comments') %></h2>
<% @post.comments.each do |c| %>
<p>
<b><%=h c.name %> said:</b><br />
<%= time_ago_in_words(c.created_at) %> ago
</p>
<p>
<%=h c.body %>
</p>
<% end %>
<%= form_for Comment.new, :url => panel_blog_comments_path do |f| %>
<p>
<%= f.label :name, "Author" %><br />
<%= f.text_field :name %><br />
<%= f.label :body, "Comment Description" %><br />
<%= f.text_area :body %>
<%= hidden_field_tag :post_id, @post.id %>
</p>
<p>
<%= f.submit "Add Comment" %>
</p>
<% end %>
<%= link_to t('blog.edit'), edit_panel_blog_post_path(@post) %> |
<%= link_back %>

View File

@ -0,0 +1,16 @@
<%=stylesheet_link_tag "NewBlog/application"%>
<div class="widget_index">
<table>
<tr>
<th><%= t('blog.title') %></th>
<th><%= t('blog.body') %></th>
</tr>
<% @posts.each do |post| %>
<tr>
<td><%= link_to post.title,panel_blog_post_path(post) %></td>
<td><%= post.body.truncate(14) %></td>
</tr>
<% end %>
</table>
</div>

View File

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

View File

@ -0,0 +1,16 @@
<%=stylesheet_link_tag "NewBlog/application"%>
<div class="widget_index">
<table>
<tr>
<th><%= t('blog.title') %></th>
<th><%= t('blog.body') %></th>
</tr>
<% @posts.each do |post| %>
<tr>
<td><%= link_to post.title,panel_blog_front_end_post_path(post) %></td>
<td><%= post.body.truncate(14) %></td>
</tr>
<% end %>
</table>
</div>

View File

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

View File

@ -0,0 +1,20 @@
zh_tw:
_locale: 中文
add: 新增
back: 回去
create: 創造
delete: 刪除
disable: 禁用
edit: 編輯
enable: 啟用
hide: 隱藏
homepage: 首頁
no_: "No"
nothing:
show: 顯示
sure?: 您肯定嗎?
update: 更新
yes_: "Yes"

13
vendor/plugins/NewBlog/config/routes.rb vendored Normal file
View File

@ -0,0 +1,13 @@
Rails.application.routes.draw do
namespace :panel do
namespace :blog do
root :to => "posts#index"
resources :posts
resources :comments
match "widget_latest_post" => "posts#widget_latest_post"
match "widget_index" => "posts#widget_index"
end
end
end