public
Fork of stevenbristol/lovd-by-less
Description: Integrate Ankoder Video Professional Service with lovd-by-less
Homepage: http://www.ankoder.com
Clone URL: git://github.com/janx/lovd-by-less.git
Search Repo:
initial commit, with a work integration
janx (author)
Thu Jul 24 18:33:50 -0700 2008
commit  0d93ecde6e493a466fbbcec435c3454cb794e2fe
tree    be59b9ca16105525ab5f27dc92be2ba49885c905
parent  4199b3764ac0ca6da8a19c3916a51d04c640bdbb
0
...
19
20
21
22
23
24
25
26
 
 
 
27
28
29
...
19
20
21
 
 
 
 
 
22
23
24
25
26
27
0
@@ -19,11 +19,9 @@ Quick Setup (currently for non-Windows users only - due to ferret gem issues):
0
   1. Edit config/database.yml.tmp to reflect the database names you would like to use.
0
   2. Edit config/environments/production.rb so asset_host reflects the name of the production asset server
0
   3. cp config/database.yml.tmp config/database.yml
0
- 4. MAKE SURE YOU UPGRADE TO GEMS 1.2.
0
- 5. RUN gem sources -a http://gems.github.com
0
- 6. rake lovdbyless:getting_started
0
- 7. rake test
0
- 8. See step #6 below to continue setup (near "Setup default values")
0
+ 4. rake lovdbyless:getting_started
0
+ 5. rake test
0
+ 6. See step #6 below to continue setup (near "Setup default values")
0
 
0
 The getting_started rake task will install all required gems, create the databases in database.yml,
0
 and migrate the development and test databases.
...
4
5
6
7
 
8
9
10
...
4
5
6
 
7
8
9
10
0
@@ -4,7 +4,7 @@ class ApplicationController < ActionController::Base
0
   filter_parameter_logging "password"
0
   
0
   
0
- before_filter :allow_to, :check_user, :set_profile, :login_from_cookie, :login_required, :check_permissions, :pagination_defaults
0
+ before_filter :allow_to, :check_user, :set_profile, :login_from_cookie, :login_required, :check_permissions, :pagination_defaults, :check_featured
0
   after_filter :store_location
0
   layout 'application'
0
   
...
12
13
14
15
16
17
18
...
12
13
14
 
15
16
17
0
@@ -12,7 +12,6 @@ class HomeController < ApplicationController
0
 
0
  
0
   def index
0
- check_featured
0
     respond_to do |wants|
0
       wants.html {render}
0
       wants.rss {render :partial => 'profiles/newest_member', :collection => new_members}
...
65
66
67
 
 
 
68
69
70
...
115
116
117
118
119
 
 
120
121
122
...
65
66
67
68
69
70
71
72
73
...
118
119
120
 
 
121
122
123
124
125
0
@@ -65,6 +65,9 @@ class Profile < ActiveRecord::Base
0
   
0
   # Photos
0
   has_many :photos, :order => 'created_at DESC'
0
+
0
+ # Videos
0
+ has_many :videos, :order => 'created_at DESC'
0
   
0
   #Forums
0
   has_many :forum_posts, :foreign_key => 'owner_id', :dependent => :destroy
0
@@ -115,8 +118,8 @@ class Profile < ActiveRecord::Base
0
       :include => :user,
0
       :conditions => ["is_active = ? and about_me IS NOT NULL and user_id is not null", true],
0
     }
0
-# find(:first, find_options.merge(:offset => rand( count(find_options) - 1)))
0
- find(:first, find_options.merge(:offset => rand(count(find_options)).floor))
0
+ all = find(:all)
0
+ all[rand(all.size)]
0
   end
0
   
0
   def no_data?
...
3
4
5
 
6
7
8
...
3
4
5
6
7
8
9
0
@@ -3,6 +3,7 @@
0
   <%= link_to 'View Public Profile', profile_path(@p).add_param(:public_view => true) %>
0
   <%= link_to 'Messages Center', messages_path unless @p.received_messages.empty? && !@p.has_network? %>
0
   <%= link_to 'Manage Photos', profile_photos_path(@p) %>
0
+ <%= link_to 'Manage Videos', profile_videos_path(@p) %>
0
   <%= link_to 'My Network', profile_friends_path(@p) if @p.has_network? %>
0
   <%= link_to 'The Blog', profile_blogs_path(@p) %>
0
   <%= link_to 'Account Settings', edit_profile_path(@p) %>
...
8
9
10
11
12
 
 
13
14
15
...
34
35
36
37
 
38
39
40
...
8
9
10
 
 
11
12
13
14
15
...
34
35
36
 
37
38
39
40
0
@@ -8,8 +8,8 @@ Rails::Initializer.run do |config|
0
   
0
   # Cookie sessions (limit = 4K)
0
   config.action_controller.session = {
0
- :session_key => '_your_app_name',
0
- :secret => 'make a secure key here'
0
+ :session_key => '__lovebyless__',
0
+ :secret => 'sdsoifjsof0293urj8920j3r02cm9m9308m2309485m294305'
0
   }
0
   config.action_controller.session_store = :active_record_store
0
 
0
@@ -34,7 +34,7 @@ Rails::Initializer.run do |config|
0
   config.gem 'hpricot', :version=>"0.6"
0
   config.gem 'mocha', :version=>"0.5.6"
0
   config.gem 'redgreen', :version=>"1.2.2"
0
- config.gem 'gcnovus-avatar', :version=>"0.0.7", :lib => 'avatar'
0
+ config.gem 'avatar', :version=>"0.0.5"
0
   
0
   
0
   
...
20
21
22
 
 
 
...
20
21
22
23
24
25
0
@@ -20,3 +20,6 @@ config.action_controller.asset_host = "http://localhost:3000"
0
 # Don't care if the mailer can't send
0
 config.action_mailer.raise_delivery_errors = true
0
 config.action_mailer.delivery_method = :test
0
+
0
+ANKODER_ACCESS_KEY = "3d07e80cac7fe03ccf8b5157c461de677ae"
0
+ANKODER_PRIVATE_KEY = "53dd447d3badf63104e388331d68da4f7dfb07aa"
...
 
1
2
3
...
1
2
3
4
0
@@ -1,3 +1,4 @@
0
+gem 'avatar', '>= 0.0.5'
0
 require 'avatar'
0
 require 'avatar/source/file_column_source'
0
 require 'avatar/source/source_chain'
...
1
2
3
4
 
5
6
7
 
...
1
2
3
 
4
5
 
6
7
0
@@ -1,6 +1,6 @@
0
 # Add the emails which should receive exception notifications below. ie: %W(admin1@yoursite.com admin2@yoursite.com)
0
 
0
 
0
-ExceptionNotifier.sender_address = %("Name Error <error@appname.url>")
0
+ExceptionNotifier.sender_address = %("LoveByLess Error <error@localhost>")
0
 ExceptionNotifier.exception_recipients = %W()
0
-ExceptionNotifier.email_prefix = "[App name Exception] "
0
\ No newline at end of file
0
+ExceptionNotifier.email_prefix = "[Love By Less Exception] "
...
4
5
6
7
8
9
 
10
11
12
...
4
5
6
 
 
 
7
8
9
10
0
@@ -4,9 +4,7 @@ ActionController::Routing::Routes.draw do |map|
0
     a.resources :users, :collection => {:search => :post}
0
   end
0
 
0
- map.resources :profiles,
0
- :member=>{:delete_icon=>:post}, :collection=>{:search=>:get},
0
- :has_many=>[:friends, :blogs, :photos, :comments, :feed_items, :messages]
0
+ map.resources :profiles, :member=>{:delete_icon=>:post}, :collection=>{:search=>:get}, :has_many => [:friends, :blogs, :photos, :videos, :comments, :feed_items, :messages]
0
 
0
   map.resources :messages, :collection => {:sent => :get}
0
   map.resources :blogs do |blog|
...
1
2
3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
...
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
0
@@ -1,2 +1,194 @@
0
-Use this README file to introduce your application and point to useful places in the API for learning more.
0
-Run "rake appdoc" to generate API documentation for your models and controllers.
0
\ No newline at end of file
0
+=Integration With LoveByLess=
0
+
0
+LoveByLess is an opensource SNS framework. We can easily integrate Ankoder with it, make it more fun.
0
+
0
+==Download and Install LoveByLess=
0
+
0
+==Install Ankoder Plugin==
0
+
0
+==Create Video Model==
0
+
0
+{{{
0
+script/generate model video name:string description:text public:boolean location:string profile_id:integer
0
+}}}
0
+
0
+Modify app/model/profile.rb, add:
0
+
0
+{{{
0
+has_many :videos, :order => 'created_at DESC'
0
+}}}
0
+
0
+Modify app/model/video.rb:
0
+
0
+{{{
0
+class Video < ActiveRecord::Base
0
+ has_many :comments, :as => :commentable, :dependent => :destroy, :order => 'created_at ASC'
0
+
0
+ belongs_to :profile
0
+
0
+ validates_presence_of :name, :profile_id
0
+
0
+ file_column :location
0
+
0
+ def after_create
0
+ feed_item = FeedItem.create(:item => self)
0
+ ([profile] + profile.friends + profile.followers).each{ |p| p.feed_items << feed_item }
0
+ end
0
+
0
+end
0
+}}}
0
+
0
+==Create Video Controller==
0
+
0
+{{{
0
+script/generate controller videos
0
+}}}
0
+
0
+Modify app/controller/videos_controller:
0
+
0
+{{{
0
+class VideosController < ApplicationController
0
+ skip_filter :login_required
0
+ prepend_before_filter :get_profile
0
+ before_filter :setup
0
+
0
+ def index
0
+ respond_to do |want|
0
+ want.html
0
+ want.rss {render :layout => false}
0
+ end
0
+ end
0
+
0
+ def show
0
+ redirect_to profile_videos_path(@profile)
0
+ end
0
+
0
+ def create
0
+ @video = @p.videos.build params[:video]
0
+
0
+ respond_to do |wants|
0
+ if @video.save
0
+ wants.html do
0
+ flash[:notice] = 'Video successfully uploaded'
0
+ redirect_to profile_videos_path(@p)
0
+ end
0
+ else
0
+ wants.html do
0
+ flash.now[:error] = 'Video could not be uploaded'
0
+ render :action => :index
0
+ end
0
+ end
0
+ end
0
+ end
0
+
0
+ private
0
+
0
+ def get_profile
0
+ @profile = Profile[params[:profile_id] || params[:id]]
0
+ end
0
+
0
+ def setup
0
+ @user = @profile.user
0
+ @videos = @profile.videos.paginate(:all, :page => @page, :per_page => @per_page)
0
+ @video = Video.new
0
+ end
0
+
0
+end
0
+}}}
0
+
0
+==Create HTML Views for Video Controller==
0
+
0
+Create app/views/videos/index.html.erb:
0
+
0
+{{{
0
+<% content_for :head do -%>
0
+<%= auto_discovery_link_tag :rss, formatted_profile_videos_url(@profile, :rss), :title=>"#{@profile.f}'s Videos" %>
0
+<% end -%>
0
+
0
+<%= render :partial => 'videos/gallery' %>
0
+}}}
0
+
0
+Create app/views/videos/index.rss.builder:
0
+
0
+{{{
0
+xml.instruct! :xml, :version=>"1.0"
0
+xml.rss(:version=>"2.0") do
0
+ xml.channel do
0
+ xml.title "#{@profile.f}'s Blog"
0
+ xml.link SITE
0
+ xml.description "#{@profile.f}'s Blog at #{SITE_NAME}"
0
+ xml.language 'en-us'
0
+ @videos.each do |video|
0
+ xml.item do
0
+ xml.title "Video"
0
+ xml.description "<a href=\"#{profile_video_url(@profile, video)}\" title=\"#{video.caption}\" alt=\"#{video.caption}\" class=\"thickbox\" rel=\"user_gallery\">#{image video, :small}</a>" + video.caption
0
+ xml.author "#{@profile.f}"
0
+ xml.pubDate @profile.created_at
0
+ xml.link profile_video_url(@profile, video)
0
+ xml.guid profile_video_url(@profile, video)
0
+ end
0
+ end
0
+ end
0
+end
0
+}}}
0
+
0
+Create app/views/videos/_gallery.html.erb:
0
+
0
+{{{
0
+<h1>Videos</h1>
0
+}}}
0
+
0
+Create app/views/videos/_form.html.erb:
0
+
0
+{{{
0
+<div id="upload_a_video">
0
+ <h2>Upload A Video</h2>
0
+
0
+ <% less_form_for [@p,@video], :html => {:multipart=>true} do |f| %>
0
+ <%= f.wrap(:image, :label => 'Video: '){file_column_field "video", "location", :size => 15} %>
0
+ <%= f.text_field :name %>
0
+ <%= f.text_area :description %>
0
+
0
+ <div class="row button">
0
+ <%= f.submit 'Upload Video', :class=>"button" %>
0
+ </div>
0
+ <% end %>
0
+
0
+ <div class="clear"></div>
0
+</div>
0
+}}}
0
+
0
+Create app/views/video/_video.html.erb:
0
+
0
+{{{
0
+<%
0
+#locals
0
+video ||= wall
0
+video ||= @video
0
+%>
0
+
0
+<div class="left image">
0
+ <div>
0
+ <a href="<%= profile_video_path(video.profile, video) %>" title="<%= video.name %>" alt="<%= video.name %>" class="thickbox" rel="user_gallery"><%= video.name %></a>
0
+ </div>
0
+ <%= link_to '(delete)', profile_video_path(video.profile, video), :method => :delete if me %>
0
+</div>
0
+}}}
0
+
0
+==Edit Profile Views==
0
+
0
+Modify app/views/profiles/_private.html.erb, add this line:
0
+
0
+{{{
0
+<%= link_to 'Manage Videos', profile_videos_path(@p) %>
0
+}}}
0
+
0
+==Add Video Resource==
0
+
0
+Modify config/routes.rb, add :photos in profiles resource:
0
+
0
+{{{
0
+ map.resources :profiles,
0
+ :member=>{:delete_icon=>:post}, :collection=>{:search=>:get},
0
+ :has_many=>[:friends, :blogs, :photos, :videos, :comments, :feed_items, :messages]
0
+}}}
...
104
105
106
107
 
108
109
110
...
104
105
106
 
107
108
109
110
0
@@ -104,7 +104,7 @@ module Footnotes
0
       insert_text :before, /<\/head>/i, <<-HTML
0
       <!-- Footnotes Style -->
0
       <style type="text/css">
0
- #footnotes_debug {margin: 2em 0 1em 0; text-align: center; color: #444; background: #bbb; line-height: 16px;}
0
+ #footnotes_debug {margin: 2em 0 1em 0; text-align: center; color: #444; line-height: 16px;}
0
         #footnotes_debug a {text-decoration: none; color: #444; line-height: 18px;}
0
         #footnotes_debug pre {overflow: scroll; margin: 0;}
0
         #footnotes_debug table {text-align: center;}

Comments

    No one has commented yet.