diff --git a/Client.html b/Client.html new file mode 100644 index 00000000..5ba9775f --- /dev/null +++ b/Client.html @@ -0,0 +1,25 @@ + + + + +Client + + + + +
+

这是一张图片

+

photo Share A

+
+ +

这是一段视频

+

Text Share B

+
+ +

这是一篇文章

+

Text Share C

+
+ + + + \ No newline at end of file diff --git a/app/assets/javascripts/shares.js b/app/assets/javascripts/shares.js new file mode 100644 index 00000000..dee720fa --- /dev/null +++ b/app/assets/javascripts/shares.js @@ -0,0 +1,2 @@ +// Place all the behaviors and hooks related to the matching controller here. +// All this logic will automatically be available in application.js. diff --git a/app/assets/stylesheets/scaffold.css b/app/assets/stylesheets/scaffold.css new file mode 100644 index 00000000..1ae70002 --- /dev/null +++ b/app/assets/stylesheets/scaffold.css @@ -0,0 +1,56 @@ +body { background-color: #fff; color: #333; } + +body, p, ol, ul, td { + font-family: verdana, arial, helvetica, sans-serif; + font-size: 13px; + line-height: 18px; +} + +pre { + background-color: #eee; + padding: 10px; + font-size: 11px; +} + +a { color: #000; } +a:visited { color: #666; } +a:hover { color: #fff; background-color:#000; } + +div.field, div.actions { + margin-bottom: 10px; +} + +#notice { + color: green; +} + +.field_with_errors { + padding: 2px; + background-color: red; + display: table; +} + +#error_explanation { + width: 450px; + border: 2px solid red; + padding: 7px; + padding-bottom: 0; + margin-bottom: 20px; + background-color: #f0f0f0; +} + +#error_explanation h2 { + text-align: left; + font-weight: bold; + padding: 5px 5px 5px 15px; + font-size: 12px; + margin: -7px; + margin-bottom: 0px; + background-color: #c00; + color: #fff; +} + +#error_explanation ul li { + font-size: 12px; + list-style: square; +} diff --git a/app/assets/stylesheets/shares.css b/app/assets/stylesheets/shares.css new file mode 100644 index 00000000..afad32db --- /dev/null +++ b/app/assets/stylesheets/shares.css @@ -0,0 +1,4 @@ +/* + Place all the styles related to the matching controller here. + They will automatically be included in application.css. +*/ diff --git a/app/controllers/shares_controller.rb b/app/controllers/shares_controller.rb new file mode 100644 index 00000000..9a76d26b --- /dev/null +++ b/app/controllers/shares_controller.rb @@ -0,0 +1,92 @@ +class SharesController < ApplicationController + # GET /shares + # GET /shares.json + def index + @shares = Share.all + + respond_to do |format| + format.html # index.html.erb + format.json { render json: @shares } + end + end + + # GET /shares/1 + # GET /shares/1.json + def show + @share = Share.find(params[:id]) + + respond_to do |format| + format.html # show.html.erb + format.json { render json: @share } + end + end + + # GET /shares/new + # GET /shares/new.json + def new + @share = Share.new + + #add by mkz 鎶撳彇鍙傛暟浼犵粰share + @share[:access_token] = params[:access_token] + @share[:comment] = params[:comment] + @share[:title] = params[:title] + @share[:url] = params[:url] + @share[:share_type] = params[:share_type] + @share.save + # + + respond_to do |format| + format.html # new.html.erb + format.json { render json: @share } + end + end + + # GET /shares/1/edit + def edit + @share = Share.find(params[:id]) + end + + # POST /shares + # POST /shares.json + def create + @share = Share.new(params[:share]) + + respond_to do |format| + if @share.save + format.html { redirect_to @share, notice: 'Share was successfully created.' } + format.json { render json: @share, status: :created, location: @share } + else + format.html { render action: "new" } + format.json { render json: @share.errors, status: :unprocessable_entity } + end + end + end + + # PUT /shares/1 + # PUT /shares/1.json + def update + @share = Share.find(params[:id]) + + respond_to do |format| + if @share.update_attributes(params[:share]) + format.html { redirect_to @share, notice: 'Share was successfully updated.' } + format.json { head :no_content } + else + format.html { render action: "edit" } + format.json { render json: @share.errors, status: :unprocessable_entity } + end + end + end + + # DELETE /shares/1 + # DELETE /shares/1.json + def destroy + @share = Share.find(params[:id]) + @share.destroy + + respond_to do |format| + format.html { redirect_to shares_url } + format.json { head :no_content } + end + end +end diff --git a/app/helpers/shares_helper.rb b/app/helpers/shares_helper.rb new file mode 100644 index 00000000..e51aa8b8 --- /dev/null +++ b/app/helpers/shares_helper.rb @@ -0,0 +1,2 @@ +module SharesHelper +end diff --git a/app/models/share.rb b/app/models/share.rb new file mode 100644 index 00000000..f597ae79 --- /dev/null +++ b/app/models/share.rb @@ -0,0 +1,3 @@ +class Share < ActiveRecord::Base + attr_accessible :access_token, :comment, :share_type, :title, :url +end diff --git a/app/views/shares/_form.html.erb b/app/views/shares/_form.html.erb new file mode 100644 index 00000000..3cf30386 --- /dev/null +++ b/app/views/shares/_form.html.erb @@ -0,0 +1,37 @@ +<%= form_for(@share) do |f| %> + <% if @share.errors.any? %> +
+

<%= pluralize(@share.errors.count, "error") %> prohibited this share from being saved:

+ + +
+ <% end %> + +
+ <%= f.label :access_token %>
+ <%= f.text_field :access_token %> +
+
+ <%= f.label :comment %>
+ <%= f.text_field :comment %> +
+
+ <%= f.label :url %>
+ <%= f.text_field :url %> +
+
+ <%= f.label :title %>
+ <%= f.text_field :title %> +
+
+ <%= f.label :share_type %>
+ <%= f.number_field :share_type %> +
+
+ <%= f.submit %> +
+<% end %> diff --git a/app/views/shares/edit.html.erb b/app/views/shares/edit.html.erb new file mode 100644 index 00000000..b54061dd --- /dev/null +++ b/app/views/shares/edit.html.erb @@ -0,0 +1,6 @@ +

Editing share

+ +<%= render 'form' %> + +<%= link_to 'Show', @share %> | +<%= link_to 'Back', shares_path %> diff --git a/app/views/shares/index.html.erb b/app/views/shares/index.html.erb new file mode 100644 index 00000000..fe06463b --- /dev/null +++ b/app/views/shares/index.html.erb @@ -0,0 +1,31 @@ +

Listing shares

+ + + + + + + + + + + + + +<% @shares.each do |share| %> + + + + + + + + + + +<% end %> +
Access tokenCommentUrlTitleShare type
<%= share.access_token %><%= share.comment %><%= share.url %><%= share.title %><%= share.share_type %><%= link_to 'Show', share %><%= link_to 'Edit', edit_share_path(share) %><%= link_to 'Destroy', share, method: :delete, data: { confirm: 'Are you sure?' } %>
+ +
+ +<%= link_to 'New Share', new_share_path %> diff --git a/app/views/shares/new.html.erb b/app/views/shares/new.html.erb new file mode 100644 index 00000000..919a9f4b --- /dev/null +++ b/app/views/shares/new.html.erb @@ -0,0 +1,5 @@ +

New share

+ +<%= render 'form' %> + +<%= link_to 'Back', shares_path %> diff --git a/app/views/shares/show.html.erb b/app/views/shares/show.html.erb new file mode 100644 index 00000000..7744914e --- /dev/null +++ b/app/views/shares/show.html.erb @@ -0,0 +1,30 @@ +

<%= notice %>

+ +

+ Access token: + <%= @share.access_token %> +

+ +

+ Comment: + <%= @share.comment %> +

+ +

+ Url: + <%= @share.url %> +

+ +

+ Title: + <%= @share.title %> +

+ +

+ Share type: + <%= @share.share_type %> +

+ + +<%= link_to 'Edit', edit_share_path(@share) %> | +<%= link_to 'Back', shares_path %> diff --git a/config/routes.rb b/config/routes.rb index 51daeb28..481fd057 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -16,6 +16,9 @@ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. RedmineApp::Application.routes.draw do + resources :shares + + get "tags/index" get "tags/show" diff --git a/db/migrate/20130801081314_create_shares.rb b/db/migrate/20130801081314_create_shares.rb new file mode 100644 index 00000000..755de055 --- /dev/null +++ b/db/migrate/20130801081314_create_shares.rb @@ -0,0 +1,13 @@ +class CreateShares < ActiveRecord::Migration + def change + create_table :shares do |t| + t.string :access_token + t.string :comment + t.string :url + t.string :title + t.integer :share_type + + t.timestamps + end + end +end diff --git a/db/schema.rb b/db/schema.rb index a6de651e..4bae3d3b 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended to check this file into your version control system. -ActiveRecord::Schema.define(:version => 20130729033444) do +ActiveRecord::Schema.define(:version => 20130801081314) do create_table "a_user_watchers", :force => true do |t| t.string "name" @@ -516,12 +516,13 @@ ActiveRecord::Schema.define(:version => 20130729033444) do add_index "settings", ["name"], :name => "index_settings_on_name" create_table "shares", :force => true do |t| - t.string "title" - t.string "type" + t.string "access_token" + t.string "comment" t.string "url" - t.date "created_on" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false + t.string "title" + t.integer "share_type" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false end create_table "students", :force => true do |t|