Class LogisController
In: app/controllers/logis_controller.rb
Parent: ApplicationController

Methods

Constants

GET_TAG_STRS_REGEX = /\=([\w\S]+?)(?:\&|$)/   Constants

Public Instance methods

REST-methods

[Source]

    # File app/controllers/logis_controller.rb, line 57
57:   def auto_complete_for_logi_browse_list_input
58:     re = Regexp.new("^#{params[:search]}", "i")
59:     find_options = { :order => "string ASC" }
60:     @tags = UsedTag.find(:all, find_options).collect(&:string).select { |t| 
61:         t.match re }
62:     render :inline =>
63:         "<%= content_tag(:ul, @tags.map { |t| content_tag(:li, h(t)) }) %>"
64:   end

Misc actions

[Source]

     # File app/controllers/logis_controller.rb, line 258
258:   def check
259:     @check_link = Link.new_from_s(params[:check_ll_link_string])
260:     @check_link.resolve
261:     respond_to do |format|
262:       format.js do
263:         if !@check_link.errors.empty?
264:           @check_link = nil
265:         end
266:         render :template => 'logis/check.js.rjs', :locals => {
267:             :name => params[:name]}
268:       end
269:     end
270:   end

[Source]

     # File app/controllers/logis_controller.rb, line 139
139:   def create
140:     respond_to do |format|
141:       format.html do
142:         logi_hash = params[:logi].dup
143:         if logi_hash[:link_string].nil? or logi_hash[:link_string].empty?
144:           logi_hash[:link_string] = Tag.sandbox.to_s
145:         end
146:         @logi, @logi_version = self.create_logi(logi_hash)
147: 
148:         if self.thorny_form_free_of_spam? and @logi.save
149:           flash[:notice] = t 'c.logis.created',
150:               :logi => @logi.to_s(:for => :full_show)
151:           redirect_to logi_ll_url(@logi)
152:         else
153:           render :action => 'new'
154:         end
155:       end
156:       format.xml do # no anonymous API posts
157:         if INSTALLED_RATOM
158:           entry = Atom::Entry.load_entry(request.body.readlines.join())
159:           @logi, @logi_version = self.create_logi(
160:               :title => entry.title,
161:               :body => entry.content,
162:               :link_string => entry.categories.collect {|c| c.term}.join('/'))
163: 
164:           if !current_user.anonymous? and @logi.save
165:             render :partial => 'show.xml.erb', :status => :created,
166:                 :location => @logi.link.to_s
167:           else
168:             render :xml => @logi.errors, :status => :unprocessable_entity
169:           end
170:         else
171:           raise "Needs ratom gem installed"
172:         end
173:       end
174:     end
175:   end

[Source]

     # File app/controllers/logis_controller.rb, line 239
239:   def destroy
240:     if @logi.admin_rights?(current_user)
241:       if @logi.destroy
242:         flash[:notice] = t 'c.logis.deleted',
243:             :logi => @logi.to_s(:for => :full_show)
244:         @logi.reload
245:         redirect_to root_url
246:       else
247:         flash[:error] = t 'c.logis.error_deleting'
248:         redirect_to logi_url(@logi)
249:       end
250:     else
251:       flash[:warning] = t 'c.logis.error_admin_permission'
252:       redirect_to logi_url(@logi)
253:     end
254:   end

[Source]

     # File app/controllers/logis_controller.rb, line 177
177:   def edit
178:     if !@logi.edit_rights?(current_user)
179:       flash[:warning] = t 'c.logis.error_permission'
180:       redirect_to logi_ll_url(@logi)
181:       return
182:     end
183: 
184:     respond_to do |format|
185:       format.html
186:       format.js do
187:         self.new_edit_js_response
188:         if !params[:selected]
189:           render :template => 'logis/index_new_edit.js.rjs', :locals => {
190:               :name => "logi_tags_edit_list", 
191:               :url => (current_context.link.to_s + '/do/edit')}
192:         end
193:       end
194:     end
195:   end

[Source]

     # File app/controllers/logis_controller.rb, line 275
275:     def fall_through
276:       html = Net::HTTP.get URI.parse("http://old.logilogi.org/" +
277:           current_context.link.to_s(:step => -1).gsub('_',''))
278:       confirmed = false
279:       if html !~ /textarea/
280:         confirmed = true
281:       end
282:       render :partial => 'fall_through', :locals => {
283:           :confirmed => confirmed}
284:     end

[Source]

     # File app/controllers/logis_controller.rb, line 66
 66:   def index
 67:     respond_to do |format|
 68:       format.html
 69:       format.js do
 70:         if params[:full_text_search]
 71:           self.get_found_full_text_logis
 72:           render :partial => 'found_full_text_logis'
 73:         else
 74:           @primary_tabs = render_to_string(:partial => 'layouts/tabs')
 75:           if current_context.tags?
 76:             @add_tag_button = render_to_string(:partial => 'add_tag_button',
 77:                 :locals => {:name => 'browse_list',
 78:                     :button_text => t('v.logis.add_word_or_tag')})
 79:             @clear_button = render_to_string(:partial => 'clear_button',
 80:                 :locals => {:name => 'browse_list', 
 81:                     :button_text => t('v.logis.clear_query')})
 82:           else
 83:             @add_tag_button = render_to_string(:partial => 'add_tag_button',
 84:                 :locals => {:name => 'browse_list',
 85:                     :button_text => t('v.logis.search_word_or_tag'),
 86:                     :button_class => 'go_button'})
 87:             @clear_button = ""
 88:           end
 89:           render :template => 'logis/index_new_edit.js.rjs', :locals => {
 90:               :name => "browse_list",
 91:               :url => ('/do/logis' + (current_context.link? ? '/' + current_context.link.to_s : '')),
 92:               :with_main => true}
 93:         end
 94:       end
 95:       format.xml do
 96:         if !current_context.link?
 97:           @logis = Logi.find(:all)
 98:           render :xml => @logis
 99:         end
100:       end
101:     end
102:   end

[Source]

     # File app/controllers/logis_controller.rb, line 125
125:   def new
126:     respond_to do |format|
127:       format.html
128:       format.js do
129:         self.new_edit_js_response
130:         if !params[:selected]
131:           render :template => 'logis/index_new_edit.js.rjs', :locals => {
132:               :name => "logi_tags_edit_list", 
133:               :url => ((current_context.link? ? '/' + current_context.link.to_s : '') + '/do/new')}
134:         end
135:       end
136:     end
137:   end

[Source]

     # File app/controllers/logis_controller.rb, line 287
287:   def new_edit_js_response
288:     if params[:selected]
289:       @selected = params[:selected]
290:       select_body(@selected)
291:     else
292:       @primary_tabs = render_to_string(:partial => 'layouts/tabs')
293:       if current_context.tags?
294:         @add_tag_button = render_to_string(:partial => 'add_tag_button',
295:             :locals => {:name => 'logi_tags_edit_list'})
296:         @clear_button = render_to_string(:partial => 'clear_button',
297:             :locals => {:name => 'logi_tags_edit_list'})
298:       else
299:         @add_tag_button = render_to_string(:partial => 'add_tag_button',
300:             :locals => {:name => 'logi_tags_edit_list',
301:                 :button_text => t('v.logis.set_tag'),
302:                 :button_class => 'go_button'})
303:         @clear_button = ""
304:       end
305:     end
306:   end

Filter-methods

[Source]

     # File app/controllers/logis_controller.rb, line 310
310:   def new_logi_and_logi_version
311:     @logi = Logi.new_with(:creator => current_user,
312:         :user_group => current_prefs.user_group)
313:     @logi_version = @logi.current_logi_version
314:   end

[Source]

     # File app/controllers/logis_controller.rb, line 316
316:   def page_name
317:     if params[:action] == "index"
318:       @page_name = t 'c.logis.page_name.index'
319:       if current_context.link?
320:         @page_name += ' ' + current_context.link.to_s(
321:             :for => :show, :direction => :requested)
322:       end
323:     else
324:       if current_context.link?
325:         @page_name = self.auto_page_name + ' - ' + 
326:             current_context.link.to_s(
327:                 :for => :show, :direction => :requested)
328:       else
329:         @page_name = ""
330:       end
331:     end
332:   end

[Source]

     # File app/controllers/logis_controller.rb, line 104
104:   def show
105:     @selected = params[:selected]
106:     respond_to do |format|
107:       format.html do
108:         self.rating_and_new_vote
109:         if params[:printer_friendly]
110:           render :action => 'printer_friendly', :layout => false
111:         else
112:           @logi.visits += 1
113:           @logi.save
114:         end
115:       end
116:       format.js do
117:         select_body(@selected)
118:       end
119:       format.xml do
120:         render :partial => 'show.xml.erb'
121:       end
122:     end
123:   end

[Source]

    # File app/controllers/logis_controller.rb, line 51
51:   def single_access_allowed?
52:     ["update","create"].include?(action_name)
53:   end

[Source]

     # File app/controllers/logis_controller.rb, line 197
197:   def update
198:     if !@logi.edit_rights?(current_user)
199:       flash[:warning] = t 'c.logis.error_permission'
200:       redirect_to logi_ll_url(@logi)
201:       return
202:     end
203: 
204:     respond_to do |format|
205:       format.html do
206:         @logi, @logi_version = self.update_logi(@logi, params[:logi])
207: 
208:         if @logi.errors.empty? and @logi.valid? and @logi_version.valid? and
209:             self.thorny_form_free_of_spam?
210:           @logi.update_if_changed(@logi_version)
211:           flash[:notice] = t 'c.logis.saved',
212:               :logi => @logi.to_s(:for => :full_show)
213:           redirect_to logi_ll_url(@logi)
214:         else
215:           render :action => 'edit'
216:         end
217:       end
218:       format.xml do
219:         if INSTALLED_RATOM
220:           entry = Atom::Entry.load_entry(request.body.readlines.join())
221:           @logi, @logi_version = self.update_logi(@logi,
222:               :title => entry.title,
223:               :body => entry.content,
224:               :link_string => entry.categories.collect {|c| c.term}.join('/'))
225: 
226:           if @logi.errors.empty? and @logi.valid? and @logi_version.valid?
227:             @logi.update_if_changed(@logi_version)
228:             head :ok
229:           else
230:             render :xml => @logi.errors, :status => :unprocessable_entity
231:           end
232:         else
233:           raise "Needs ratom gem installed"
234:         end
235:       end
236:     end
237:   end

Protected Instance methods

[Source]

     # File app/controllers/logis_controller.rb, line 498
498:   def activity
499:     case @logi.kind
500:     when Const::Logi::KINDS[:peer_group]
501:       render_body 'peer_groups/activity', :locals => {
502:           :peer_group => @logi.home_pages_peer_group}
503:     else
504:       return false
505:     end
506:   end

[Source]

     # File app/controllers/logis_controller.rb, line 416
416:   def cloud
417:     if !current_context.tags?
418:       @used_tags = UsedTag.top_used_tags(:limit => 57, :no_special => true)
419:     else
420:       @used_tags = current_context.suggested_used_tags(:limit => 57)
421:     end
422:   end

[Source]

     # File app/controllers/logis_controller.rb, line 446
446:   def comments
447:     @selected = params[:selected]
448:     self.get_logis
449:     render_ajax_body :partial => 'snippets_pagination', :locals => {
450:         :logis => @logis, :selected => @selected}
451:   end
comments_on()

Alias for side_menu_selected

contending_logis()

Alias for side_menu_selected

Body-methods

[Source]

     # File app/controllers/logis_controller.rb, line 338
338:   def description
339:     if !current_context.link?
340:       render_body 'logis/small_snippet',
341:           :locals => {:logi => Logi.main_page, :id => 'site_description'}
342:     end
343:   end

[Source]

     # File app/controllers/logis_controller.rb, line 369
369:   def found_logis
370:     if current_context.link?
371:       @exact_matching_logis = current_context.exact_matching_logis
372:       @sloppy_matching_logis = current_context.sloppy_matching_logis
373:       @reduced_matching_logis = current_context.reduced_matching_logis
374:       if !current_context.matches?
375:         self.get_found_full_text_logis
376:       else
377:         @full_text_logis = nil
378:       end
379:       true
380:     end
381:   end

[Source]

     # File app/controllers/logis_controller.rb, line 383
383:   def get_found_full_text_logis
384:     @full_text_logis = WillPaginate::Collection.create(
385:         (params[:page] || 1), 8) do |pager|
386:       search = ActsAsXapian::Search.new([Logi], current_context.query,
387:           :offset => pager.offset, :limit => pager.per_page)
388:       # inject the result array into the paginated collection:
389:       pager.replace(search.results.collect {|r| r[:model]})
390: 
391:       unless pager.total_entries
392:         # the pager didn't manage to guess the total count, do it manually
393:         pager.total_entries = search.matches_estimated
394:       end
395:     end
396:   end

[Source]

     # File app/controllers/logis_controller.rb, line 424
424:   def get_logis
425:     case @logi.kind
426:     when Const::Logi::KINDS[:peer_group]
427:       ratings = @logi.home_pages_peer_group.ratings.recent.positive.paginate(
428:           :page => params[:page], :per_page => 8)
429:       @logis = ratings.replace(ratings.collect {|r| r.logi})
430:     else
431:       @logis = @logi.commenting_logis.paginate(
432:           :page => params[:page], :per_page => 8)
433:     end
434:   end
home_page()

Alias for side_menu_selected

incoming_links()

Alias for side_menu_selected

[Source]

     # File app/controllers/logis_controller.rb, line 410
410:   def incoming_links_to_tags
411:     if current_context.tags?
412:       @to_tags_links = current_context.incoming_links_to_tags
413:     end
414:   end

[Source]

     # File app/controllers/logis_controller.rb, line 436
436:   def logis
437:     self.get_logis
438:     case @logi.kind
439:     when Const::Logi::KINDS[:peer_group]
440:       render_ajax_body :partial => 'rated_by_peer_group', :locals => {:logis => @logis}
441:     else
442:       render_ajax_body :partial => 'comments', :locals => {:logis => @logis}
443:     end
444:   end

Url-bars with context.

[Source]

     # File app/controllers/logis_controller.rb, line 520
520:   def navigation_bar
521:     if params[:action] == "new" or params[:action] == "create"
522:       render_body 'navigation_bar_new'
523:     elsif params[:action] == "edit" or params[:action] == "update"
524:       render_body 'navigation_bar_edit'
525:     elsif params[:action] == "show"
526:       render_body 'navigation_bar_view'
527:     elsif params[:action] == "index"
528:       render_body 'navigation_bar_browse'
529:     end
530:     return false
531:   end

[Source]

     # File app/controllers/logis_controller.rb, line 469
469:   def new_edit_side_menu
470:     if @body_selected or !params[:selected]
471:       if !@selected
472:         @selected = "contending_logis"
473:       end
474:       self.side_menu_selected
475:     end
476:   end

[Source]

     # File app/controllers/logis_controller.rb, line 352
352:   def new_logis
353:     if !current_context.link?
354:       @new_logis_count = Logi.count(:conditions => 
355:           'created_at > "' + 1.week.ago.to_s(:db) + '"')
356:       @logis = Logi.recent.presentable.paginate(:page => params[:page],
357:           :per_page => 7)
358:     end
359:   end

[Source]

     # File app/controllers/logis_controller.rb, line 361
361:   def new_users
362:     if !current_context.link?
363:       @users = User.find(:all, :order => 'created_at DESC', :limit => 15)
364:       @new_users_count = User.count(:conditions => 'created_at > "' +
365:           1.week.ago.to_s(:db) + '"')
366:     end
367:   end
paths()

Alias for side_menu_selected

rated_by_peer_group()

Alias for comments

[Source]

     # File app/controllers/logis_controller.rb, line 508
508:   def remarks_and_recent_votes
509:     @remark = Remark.new
510:     @votes_count = @logi.rating_for(
511:         current_prefs.peer_group).votes.count
512:     @positive_votes = @logi.rating_for(
513:         current_prefs.peer_group).votes.positive[0..10]
514:     @remarks = @logi.remarks.find(:all, 
515:         :limit => 10, :order => ["created_at DESC"])
516:   end

[Source]

     # File app/controllers/logis_controller.rb, line 345
345:   def screencast
346:     if !current_context.link? and (current_user.anonymous? or 
347:         current_user.created_at < 10.days.ago)
348:       return true
349:     end
350:   end

[Source]

     # File app/controllers/logis_controller.rb, line 454
454:   def side_menu
455:     if !@selected
456:       if @logi.untagged? and @logi.comments_on_logis.size > 0
457:         @selected = "comments_on"
458:       elsif @logi.home_page?
459:         @selected = "home_page"
460:       elsif !@logi.steps.empty?
461:         @selected = "paths"
462:       else
463:         @selected = "contending_logis"
464:       end
465:     end
466:     self.side_menu_selected
467:   end

[Source]

     # File app/controllers/logis_controller.rb, line 478
478:   def side_menu_selected
479:     if @selected == "paths"
480:       @path = @logi.steps.first.path
481:     end
482: 
483:     if params[:selected] # a tab has been clicked
484:       render_ajax_body :partial => 'side_menu.html.erb', :locals => {
485:           :selected => @selected}
486:     else
487:       render_body :partial => 'side_menu.html.erb', :locals => {
488:           :selected => @selected}
489:     end
490:   end

[Source]

     # File app/controllers/logis_controller.rb, line 398
398:   def tag_sets
399:     if current_context.link?
400:       if current_context.matches?
401:         @tag_set_links = current_context.tag_set_links
402:       else
403:         # MAYDO: Can be optimized by special TagSet class in search index
404:         @tag_set_links = Context.extract_tag_set_links(
405:             LogiLogiXapian.search([Logi], current_context.query))
406:       end
407:     end
408:   end

[Validate]