fcid 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/MIT-LICENSE +20 -0
- data/README.rdoc +3 -0
- data/Rakefile +22 -0
- data/app/controllers/fcid/feeds_controller.rb +22 -0
- data/app/controllers/fcid/friendships_controller.rb +74 -0
- data/app/controllers/fcid/messages_controller.rb +24 -0
- data/app/controllers/fcid/session_controller.rb +80 -0
- data/app/controllers/fcid/users_controller.rb +25 -0
- data/app/views/fcid/_ajax_new.html.erb +3 -0
- data/app/views/fcid/_announce.html.erb +5 -0
- data/app/views/fcid/_footer.html.erb +0 -0
- data/app/views/fcid/_navigation.html.erb +0 -0
- data/app/views/fcid/create.html.erb +6 -0
- data/app/views/fcid/feeds/_feed.html.erb +29 -0
- data/app/views/fcid/feeds/index.html.erb +4 -0
- data/app/views/fcid/feeds/show.html.erb +0 -0
- data/app/views/fcid/friendships/index.html.erb +5 -0
- data/app/views/fcid/friendships/new.html.erb +22 -0
- data/app/views/fcid/messages/_message.html.erb +0 -0
- data/app/views/fcid/messages/_message_tr.html.erb +8 -0
- data/app/views/fcid/messages/index.html.erb +20 -0
- data/app/views/fcid/new.html.erb +30 -0
- data/app/views/fcid/session/new.html.erb +40 -0
- data/app/views/fcid/users/_ajax_new.html.erb +3 -0
- data/app/views/fcid/users/create.html.erb +6 -0
- data/app/views/fcid/users/new.html.erb +33 -0
- data/app/views/friendships/new.html.erb +22 -0
- data/app/views/session/new.html.erb +20 -0
- data/config/routes.rb +29 -0
- data/lib/fcid/active_resource/exceptions.rb +7 -0
- data/lib/fcid/active_resource/extra_params.rb +66 -0
- data/lib/fcid/active_resource/session.rb +45 -0
- data/lib/fcid/base.rb +7 -0
- data/lib/fcid/config.rb +88 -0
- data/lib/fcid/consumer.rb +51 -0
- data/lib/fcid/controller.rb +46 -0
- data/lib/fcid/email.rb +9 -0
- data/lib/fcid/engine.rb +5 -0
- data/lib/fcid/feed.rb +17 -0
- data/lib/fcid/friendship.rb +5 -0
- data/lib/fcid/helpers.rb +49 -0
- data/lib/fcid/message.rb +5 -0
- data/lib/fcid/notification.rb +5 -0
- data/lib/fcid/publisher/base.rb +398 -0
- data/lib/fcid/session.rb +5 -0
- data/lib/fcid/user.rb +50 -0
- data/lib/fcid/user_methods.rb +39 -0
- data/lib/fcid/version.rb +3 -0
- data/lib/fcid.rb +12 -0
- data/lib/fcid_client.rb +14 -0
- data/lib/tasks/fcid_tasks.rake +4 -0
- data/lib/vendor/authenticated_system.rb +153 -0
- data/lib/vendor/authenticated_test_helper.rb +11 -0
- data/test/dummy/README.rdoc +261 -0
- data/test/dummy/Rakefile +7 -0
- data/test/dummy/app/assets/javascripts/application.js +15 -0
- data/test/dummy/app/assets/stylesheets/application.css +13 -0
- data/test/dummy/app/controllers/application_controller.rb +3 -0
- data/test/dummy/app/helpers/application_helper.rb +2 -0
- data/test/dummy/app/views/layouts/application.html.erb +14 -0
- data/test/dummy/config/application.rb +59 -0
- data/test/dummy/config/boot.rb +10 -0
- data/test/dummy/config/database.yml +25 -0
- data/test/dummy/config/environment.rb +5 -0
- data/test/dummy/config/environments/development.rb +37 -0
- data/test/dummy/config/environments/production.rb +67 -0
- data/test/dummy/config/environments/test.rb +37 -0
- data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/test/dummy/config/initializers/inflections.rb +15 -0
- data/test/dummy/config/initializers/mime_types.rb +5 -0
- data/test/dummy/config/initializers/secret_token.rb +7 -0
- data/test/dummy/config/initializers/session_store.rb +8 -0
- data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/test/dummy/config/locales/en.yml +5 -0
- data/test/dummy/config/routes.rb +58 -0
- data/test/dummy/config.ru +4 -0
- data/test/dummy/public/404.html +26 -0
- data/test/dummy/public/422.html +26 -0
- data/test/dummy/public/500.html +25 -0
- data/test/dummy/public/favicon.ico +0 -0
- data/test/dummy/script/rails +6 -0
- data/test/fcid_test.rb +9 -0
- data/test/test_helper.rb +15 -0
- metadata +169 -0
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2008 [name of plugin creator]
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
data/Rakefile
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'rake'
|
2
|
+
require 'rake/testtask'
|
3
|
+
require 'rake/rdoctask'
|
4
|
+
|
5
|
+
desc 'Default: run unit tests.'
|
6
|
+
task :default => :test
|
7
|
+
|
8
|
+
desc 'Test the fcid plugin.'
|
9
|
+
Rake::TestTask.new(:test) do |t|
|
10
|
+
t.libs << 'lib'
|
11
|
+
t.pattern = 'test/**/*_test.rb'
|
12
|
+
t.verbose = true
|
13
|
+
end
|
14
|
+
|
15
|
+
desc 'Generate documentation for the fcid plugin.'
|
16
|
+
Rake::RDocTask.new(:rdoc) do |rdoc|
|
17
|
+
rdoc.rdoc_dir = 'rdoc'
|
18
|
+
rdoc.title = 'Fcid'
|
19
|
+
rdoc.options << '--line-numbers' << '--inline-source'
|
20
|
+
rdoc.rdoc_files.include('README')
|
21
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
22
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
class Fcid::FeedsController < ApplicationController
|
3
|
+
|
4
|
+
def index
|
5
|
+
@user = Fcid::User.find current_user.id
|
6
|
+
Fcid::Feed.with_session @user do
|
7
|
+
@feeds = Fcid::Feed.find :all
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
def show
|
12
|
+
@feed = Fcid::Feed.find params[:id]
|
13
|
+
end
|
14
|
+
|
15
|
+
def destroy
|
16
|
+
@feed = Fcid::Feed.find params[:id]
|
17
|
+
@feed.destroy
|
18
|
+
flash[:notice] = "删除成功"
|
19
|
+
redirect_to fcid_feeds_path
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
@@ -0,0 +1,74 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
class Fcid::FriendshipsController < ApplicationController
|
3
|
+
|
4
|
+
layout :calc_layout
|
5
|
+
|
6
|
+
before_filter :login_required
|
7
|
+
|
8
|
+
# 输出 json 和 xml 或者其他的一些信息
|
9
|
+
# 可能得缓存,具体方案得研究
|
10
|
+
def index
|
11
|
+
Fcid::Friendship.with_session current_user do
|
12
|
+
@friendships = Fcid::Friendship.find :all
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def create
|
17
|
+
Fcid::Friendship.with_session current_user do
|
18
|
+
logger.debug current_user.fcid_auth_token
|
19
|
+
@user = Fcid::User.find current_user.id
|
20
|
+
@friendship = Fcid::Friendship.new params[:fcid_friendship]
|
21
|
+
@friendship.user_id = @user.id
|
22
|
+
@success = @friendship.save
|
23
|
+
end
|
24
|
+
respond_to do |format|
|
25
|
+
|
26
|
+
format.html do
|
27
|
+
if @success
|
28
|
+
flash[:notice] = "操作成功"
|
29
|
+
else
|
30
|
+
flash[:error] = @friendship.errors.full_messages.first
|
31
|
+
end
|
32
|
+
@redirect_to = params[:redirect_to]
|
33
|
+
if @redirect_to.blank?
|
34
|
+
redirect_to :back
|
35
|
+
else
|
36
|
+
redirect_to @redirect_to
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
|
41
|
+
format.js do
|
42
|
+
render :update do |page|
|
43
|
+
page.alert("yes")
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
def new
|
51
|
+
friend_id = params[:friend_id]
|
52
|
+
@friend = Fcid::User.find params[:friend_id]
|
53
|
+
if @friend.friend?(current_user)
|
54
|
+
# 已经是朋友了
|
55
|
+
else
|
56
|
+
@friendship = Fcid::Friendship.new :note=>nil,:friend_id=>friend_id,:user_id=>nil
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
def destroy
|
61
|
+
friend_id = params[:friend_id]
|
62
|
+
@friend = Fcid::User.find params[:friend_id]
|
63
|
+
end
|
64
|
+
|
65
|
+
protected
|
66
|
+
def calc_layout
|
67
|
+
if params[:nolayout]
|
68
|
+
false
|
69
|
+
else
|
70
|
+
nil
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
class Fcid::MessagesController < ApplicationController
|
3
|
+
|
4
|
+
def index
|
5
|
+
@user = Fcid::User.find current_user.id
|
6
|
+
Fcid::Message.with_session @user do
|
7
|
+
@messages = Fcid::Message.find :all
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
def show
|
12
|
+
@message = Fcid::Message.find params[:id]
|
13
|
+
end
|
14
|
+
|
15
|
+
def create
|
16
|
+
end
|
17
|
+
|
18
|
+
def new
|
19
|
+
end
|
20
|
+
|
21
|
+
def destroy
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
@@ -0,0 +1,80 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
class Fcid::SessionController < ApplicationController
|
3
|
+
|
4
|
+
def oauth
|
5
|
+
oauth_token,oauth_verifier = params[:oauth_token] , params[:oauth_verifier]
|
6
|
+
if oauth_token && oauth_verifier
|
7
|
+
@access_token = session[:request_token].get_access_token :oauth_verifier => oauth_verifier
|
8
|
+
hash = Hash.from_xml @access_token.get("/users/me.xml").body
|
9
|
+
user_hash = hash['user']
|
10
|
+
# ::User.sync(@user['id'])
|
11
|
+
user = ::User.find_or_initialize_by_id(user_hash['id'])
|
12
|
+
user_hash.each_pair do |key,value|
|
13
|
+
# user[key] = value
|
14
|
+
end
|
15
|
+
user[:uname] = user_hash['username']
|
16
|
+
user[:avatar] = user_hash['avatar']
|
17
|
+
user[:access_token] = @access_token.token
|
18
|
+
user[:access_secret] = @access_token.secret
|
19
|
+
user.save!
|
20
|
+
|
21
|
+
self.current_user = user
|
22
|
+
url = params[:redirect_to] || session[:redirect_to] || root_path
|
23
|
+
session.delete :redirect_to
|
24
|
+
redirect_to url
|
25
|
+
else
|
26
|
+
# 先检测是否登录了 fcid
|
27
|
+
@request_token = Fcid.consumer.get_request_token
|
28
|
+
session[:request_token] = @request_token
|
29
|
+
redirect_to @request_token.authorize_url + "&dialog=1"
|
30
|
+
end
|
31
|
+
rescue OAuth::Unauthorized=> e
|
32
|
+
(flash[:error] = "无权访问,请确认配置文件设置是否正确(api_key,api_secret)") && redirect_to(:back)
|
33
|
+
end
|
34
|
+
|
35
|
+
def create
|
36
|
+
if fcid_user = Fcid::User.authenticate(params[:username_or_email], params[:password])
|
37
|
+
::User.sync(fcid_user["id"])
|
38
|
+
self.current_user = ::User.find(fcid_user["id"])
|
39
|
+
end
|
40
|
+
if logged_in?
|
41
|
+
respond_to do |format|
|
42
|
+
format.html do
|
43
|
+
flash[:notice] = "登录成功。"
|
44
|
+
url = params[:redirect_to] || session[:redirect_to] || root_path
|
45
|
+
session.delete :redirect_to
|
46
|
+
redirect_to url
|
47
|
+
end
|
48
|
+
|
49
|
+
format.js do
|
50
|
+
end
|
51
|
+
end
|
52
|
+
else
|
53
|
+
flash[:error] = "登录失败,请确认你输入的信息是正确的,或者此用户未被激活"
|
54
|
+
redirect_to new_fcid_session_path
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
def new
|
59
|
+
if params[:redirect_to]
|
60
|
+
session[:redirect_to] = params[:redirect_to]
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
def destroy
|
65
|
+
cookies.delete :auth_token
|
66
|
+
cookies.delete :fcid_auth_token #删除passport上面的cookie,防止再次通过passport上的cookie登录
|
67
|
+
session.delete :user
|
68
|
+
session.delete :user_id
|
69
|
+
flash[:notice] = "您已经成功退出系统。"
|
70
|
+
redirect_to(:back)
|
71
|
+
end
|
72
|
+
|
73
|
+
# sync user infomation from fcid.net
|
74
|
+
def sync
|
75
|
+
::User.sync(current_user.id) if logged_in?
|
76
|
+
flash[:notice] = "同步成功"
|
77
|
+
redirect_to_back_or_default '/'
|
78
|
+
end
|
79
|
+
|
80
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
class Fcid::UsersController < ApplicationController
|
3
|
+
# Be sure to include AuthenticationSystem in Application Controller instead
|
4
|
+
def new
|
5
|
+
@user = Fcid::User.new
|
6
|
+
respond_to do |format|
|
7
|
+
format.html
|
8
|
+
format.text do
|
9
|
+
render :partial=>"ajax_new"
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def destroy
|
15
|
+
end
|
16
|
+
|
17
|
+
def create
|
18
|
+
@user = Fcid::User.new params[:fcid_user]
|
19
|
+
if @user.save
|
20
|
+
# it will render an create.html.erb
|
21
|
+
else
|
22
|
+
render :action=>"new"
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
File without changes
|
File without changes
|
@@ -0,0 +1,29 @@
|
|
1
|
+
<%= time_separator feed.created_at %>
|
2
|
+
<div class="fcid-feed clear">
|
3
|
+
<div class="fcid-feed-left">
|
4
|
+
<div class="fcid-feed-avatar">
|
5
|
+
<%= avatar feed.actor %>
|
6
|
+
</div>
|
7
|
+
</div>
|
8
|
+
|
9
|
+
<div class="fcid-feed-right">
|
10
|
+
<div class="fcid-feed-title">
|
11
|
+
<%= feed.title %>
|
12
|
+
<div class="fcid-feed-time">
|
13
|
+
<%= time_ago_in_words feed.created_at %>
|
14
|
+
</div>
|
15
|
+
</div>
|
16
|
+
<div class="fcid-feed-body">
|
17
|
+
<%= feed.body %>
|
18
|
+
</div>
|
19
|
+
<div class="fcid-feed-pictures">
|
20
|
+
<% feed.pictures.each do |picture| %>
|
21
|
+
<div class="fcid-feed-picture">
|
22
|
+
<%= link_to image_tag(picture[:url]),picture[:link] %>
|
23
|
+
</div>
|
24
|
+
<% end %>
|
25
|
+
</div>
|
26
|
+
<div class="fcid-feed-setting">
|
27
|
+
</div>
|
28
|
+
</div>
|
29
|
+
</div>
|
File without changes
|
@@ -0,0 +1,22 @@
|
|
1
|
+
<div class="show-box clear">
|
2
|
+
<div class="show-box-left">
|
3
|
+
<p><%= avatar @friend %></p>
|
4
|
+
<p><%= uname @friend %></p>
|
5
|
+
</div>
|
6
|
+
<div class="show-box-right">
|
7
|
+
<% remote_form_for @friendship,:url=>friendships_path do |f| %>
|
8
|
+
<%= f.hidden_field :friend_id %>
|
9
|
+
<p>
|
10
|
+
<label>附言</label>
|
11
|
+
<%= f.text_area :note %>
|
12
|
+
</p>
|
13
|
+
|
14
|
+
<p>
|
15
|
+
<label> </label>
|
16
|
+
<%= submit_tag '提交' %>
|
17
|
+
</p>
|
18
|
+
|
19
|
+
<% end %>
|
20
|
+
</div>
|
21
|
+
</div>
|
22
|
+
|
File without changes
|
@@ -0,0 +1,20 @@
|
|
1
|
+
<table class="lister messages fcid-messages">
|
2
|
+
<thead>
|
3
|
+
<tr>
|
4
|
+
<td>发送人</td>
|
5
|
+
<td>主题</td>
|
6
|
+
<td>时间</td>
|
7
|
+
</tr>
|
8
|
+
</thead>
|
9
|
+
<tbody>
|
10
|
+
<%= render :partial=>"message_tr",:collection=>@messages,:as=>:message %>
|
11
|
+
</tbody>
|
12
|
+
<tfoot>
|
13
|
+
<tr>
|
14
|
+
<td colspan="4">
|
15
|
+
<%# will_paginate @messages %>
|
16
|
+
</td>
|
17
|
+
</tr>
|
18
|
+
</tfoot>
|
19
|
+
</table>
|
20
|
+
|
@@ -0,0 +1,30 @@
|
|
1
|
+
<%= error_messages_for :user %>
|
2
|
+
<div class="box">
|
3
|
+
<h2>注册新用户</h2>
|
4
|
+
<% form_for @user,:url=>fcid_path do |f| %>
|
5
|
+
<p>
|
6
|
+
<label>用户名</label>
|
7
|
+
<%= f.text_field :username %>
|
8
|
+
</p>
|
9
|
+
|
10
|
+
<p>
|
11
|
+
<label>邮件地址</label>
|
12
|
+
<%= f.text_field :email %>
|
13
|
+
</p>
|
14
|
+
|
15
|
+
<p>
|
16
|
+
<label>密码</label>
|
17
|
+
<%= f.password_field :password %>
|
18
|
+
</p>
|
19
|
+
|
20
|
+
<p>
|
21
|
+
<label>再次输入密码</label>
|
22
|
+
<%= f.password_field :password_confirmation %>
|
23
|
+
</p>
|
24
|
+
|
25
|
+
<p class="clear">
|
26
|
+
<label> </label>
|
27
|
+
<%= submit_tag ' 注册用户 ' %>
|
28
|
+
</p>
|
29
|
+
<% end %>
|
30
|
+
</div>
|
@@ -0,0 +1,40 @@
|
|
1
|
+
<ul class="breadcrumb">
|
2
|
+
<li><%= link_to AS['site.name'],root_path %> <span class="diver">/</span></li>
|
3
|
+
<li>用户登录</li>
|
4
|
+
</ul>
|
5
|
+
<%= form_tag fcid_session_path ,:class =>"form-horizontal" do %>
|
6
|
+
<fieldset>
|
7
|
+
<legend>用户登录</legend>
|
8
|
+
<div class="control-group">
|
9
|
+
<label class="control-label">用户</label>
|
10
|
+
<div class="controls"><%= text_field_tag "username_or_email" %></div>
|
11
|
+
</div>
|
12
|
+
|
13
|
+
<div class="control-group">
|
14
|
+
<label>密码</label>
|
15
|
+
<div class="controls"><%= password_field_tag "password" %></div>
|
16
|
+
</div>
|
17
|
+
|
18
|
+
<div class="control-group">
|
19
|
+
<label> </label>
|
20
|
+
<div class="controls">
|
21
|
+
<%= submit_tag "登录",:class => "btn primary", :onclick => "form.submit();this.disabled = true;" %>
|
22
|
+
<%= link_to "注册",new_fcid_user_path %>
|
23
|
+
<%= link_to "找回密码","http://#{Fcid.host}/users/recover" %>
|
24
|
+
<%= link_to "重发邮件","http://#{Fcid.host}/users/recover" %>
|
25
|
+
<br /> <br />
|
26
|
+
<%= link_to_function "使用OAuth方式登录","window.open('#{oauth_fcid_session_path}','fcid-oauth','width=400,height=300')",:class => "btn"%>
|
27
|
+
</div>
|
28
|
+
</div>
|
29
|
+
|
30
|
+
<div class="control-group">
|
31
|
+
<label> </label>
|
32
|
+
<div class="controls">
|
33
|
+
<%= render :partial=>"fcid/announce" %>
|
34
|
+
</div>
|
35
|
+
</div>
|
36
|
+
|
37
|
+
</fieldset>
|
38
|
+
|
39
|
+
<% end %>
|
40
|
+
|
@@ -0,0 +1,33 @@
|
|
1
|
+
<%= error_messages_for :user %>
|
2
|
+
<div class="box">
|
3
|
+
<h3>注册新用户</h3>
|
4
|
+
<div>
|
5
|
+
<% form_for @user,:url=>fcid_users_path do |f| %>
|
6
|
+
<div>
|
7
|
+
<label>用户名</label>
|
8
|
+
<div><%= f.text_field :username %></div>
|
9
|
+
</div>
|
10
|
+
|
11
|
+
<div>
|
12
|
+
<label>邮件地址</label>
|
13
|
+
<div><%= f.text_field :email %></div>
|
14
|
+
</div>
|
15
|
+
|
16
|
+
<div>
|
17
|
+
<label>密码</label>
|
18
|
+
<div><%= f.password_field :password %></div>
|
19
|
+
</div>
|
20
|
+
|
21
|
+
<div>
|
22
|
+
<label>再次输入密码</label>
|
23
|
+
<div><%= f.password_field :password_confirmation %></div>
|
24
|
+
</div>
|
25
|
+
|
26
|
+
<div class="whole-line">
|
27
|
+
<%= submit_tag ' 注册用户 ' %>
|
28
|
+
</div>
|
29
|
+
<% end %>
|
30
|
+
</div>
|
31
|
+
</div>
|
32
|
+
|
33
|
+
<%= render :partial=>"fcid/announce" %>
|
@@ -0,0 +1,22 @@
|
|
1
|
+
<div class="show-box clear">
|
2
|
+
<div class="show-box-left">
|
3
|
+
<p><%= avatar @friend %></p>
|
4
|
+
<p><%= uname @friend %></p>
|
5
|
+
</div>
|
6
|
+
<div class="show-box-right">
|
7
|
+
<% remote_form_for @friendship,:url=>friendships_path do |f| %>
|
8
|
+
<%= f.hidden_field :friend_id %>
|
9
|
+
<p>
|
10
|
+
<label>附言</label>
|
11
|
+
<%= f.text_area :note %>
|
12
|
+
</p>
|
13
|
+
|
14
|
+
<p>
|
15
|
+
<label> </label>
|
16
|
+
<%= submit_tag '提交' %>
|
17
|
+
</p>
|
18
|
+
|
19
|
+
<% end %>
|
20
|
+
</div>
|
21
|
+
</div>
|
22
|
+
|
@@ -0,0 +1,20 @@
|
|
1
|
+
<% form_tag session_path do %>
|
2
|
+
<p>
|
3
|
+
<label>用户</label>
|
4
|
+
<%= text_field_tag "username_or_email" %>
|
5
|
+
</p>
|
6
|
+
|
7
|
+
<p>
|
8
|
+
<label>密码</label>
|
9
|
+
<%= password_field_tag "password" %>
|
10
|
+
</p>
|
11
|
+
|
12
|
+
<p>
|
13
|
+
<label> </label>
|
14
|
+
<%= submit_tag "登录" %>
|
15
|
+
<%= link_to "注册",new_fcid_path %>
|
16
|
+
<%= link_to "找回密码","http://#{Fcid.host}/users/recover" %>
|
17
|
+
<%= link_to "重发邮件","http://#{Fcid.host}/users/recover" %>
|
18
|
+
</p>
|
19
|
+
|
20
|
+
<% end %>
|
data/config/routes.rb
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
if Rails.version < "3"
|
4
|
+
ActionController::Routing::Routes.draw do |map|
|
5
|
+
|
6
|
+
map.namespace :fcid do |fcid|
|
7
|
+
fcid.resource :session,:controller=>"session"
|
8
|
+
fcid.resources :messages
|
9
|
+
fcid.resources :users
|
10
|
+
fcid.resources :friendships
|
11
|
+
fcid.resources :feeds
|
12
|
+
end
|
13
|
+
|
14
|
+
end
|
15
|
+
else
|
16
|
+
|
17
|
+
Rails.application.routes.draw do
|
18
|
+
namespace :fcid do
|
19
|
+
resource :session,:controller => "session" do
|
20
|
+
match :oauth
|
21
|
+
end
|
22
|
+
resources :messages
|
23
|
+
resources :users
|
24
|
+
resources :friendships
|
25
|
+
resources :feeds
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
@@ -0,0 +1,66 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
module Fcid
|
3
|
+
module ActiveResource
|
4
|
+
|
5
|
+
module Base
|
6
|
+
module ExtraParams
|
7
|
+
def self.included(base)
|
8
|
+
base.class_eval do
|
9
|
+
@@extra_params = {}
|
10
|
+
class_inheritable_accessor :extra_params
|
11
|
+
self.extra_params = {}
|
12
|
+
extend ClassMethods
|
13
|
+
class << self
|
14
|
+
alias_method_chain :connection,:extra_params
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
module ClassMethods
|
20
|
+
def connection_with_extra_params(*args)
|
21
|
+
connection = connection_without_extra_params(*args)
|
22
|
+
connection.extra_params = extra_params
|
23
|
+
connection
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
module Connection
|
31
|
+
module ExtraParams
|
32
|
+
def self.included(base)
|
33
|
+
base.class_eval do
|
34
|
+
include InstanceMethods
|
35
|
+
attr_accessor :extra_params
|
36
|
+
alias_method_chain :request,:extra_params
|
37
|
+
alias_method_chain :initialize,:extra_params
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
41
|
+
|
42
|
+
|
43
|
+
module InstanceMethods
|
44
|
+
|
45
|
+
def initialize_with_extra_params(*args,&block)
|
46
|
+
@extra_params = {}
|
47
|
+
initialize_without_extra_params *args,&block
|
48
|
+
end
|
49
|
+
|
50
|
+
def request_with_extra_params(method, path, *arguments)
|
51
|
+
unless extra_params.empty?
|
52
|
+
if path =~ /\?/
|
53
|
+
path += "&" + @extra_params.to_param
|
54
|
+
else
|
55
|
+
path += "?" + @extra_params.to_param
|
56
|
+
end
|
57
|
+
end
|
58
|
+
Rails.logger.debug "request url: #{path}"
|
59
|
+
request_without_extra_params(method,path,*arguments)
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|