Class: Gitgo::Controllers::Issue

Inherits:
Gitgo::Controller show all
Includes:
Rest
Defined in:
lib/gitgo/controllers/issue.rb

Constant Summary collapse

Issue =

actions

Documents::Issue

Constants inherited from Gitgo::Controller

Gitgo::Controller::HEAD, Gitgo::Controller::MOUNT, Gitgo::Controller::ROOT

Instance Method Summary collapse

Methods included from Rest

#create, #destroy, #edit, #preview, #preview?, #redirect_to_doc, #show, #update

Methods inherited from Gitgo::Controller

#call, #form, #format, #html, #initialize, #mount_point, #path, #repo, #session_head, #session_head=, #url

Constructor Details

This class inherits a constructor from Gitgo::Controller

Instance Method Details

#attrsObject



71
72
73
# File 'lib/gitgo/controllers/issue.rb', line 71

def attrs
  request['doc'] || {'tags' => ['open'], 'at' => session_head}
end

#indexObject



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
# File 'lib/gitgo/controllers/issue.rb', line 35

def index
  all = request['all']
  any = request['any']
  
  if tags = request['tags']
    tags = [tags] unless tags.kind_of?(Array)
    ((all ||= {})['tags'] ||= []).concat(tags)
  end
  
  issues = Issue.find(all, any)
  
  # sort results
  sort = request['sort'] || 'date'
  reverse = request['reverse'] == 'true'
  
  issues.sort! {|a, b| a[sort] <=> b[sort] }
  issues.reverse! if reverse
  
  erb :index, :locals => {
    :docs => issues,
    :any => any || {},
    :all => all || {},
    :sort => sort,
    :reverse => reverse, 
    :active_sha => session_head
  }
end

#modelObject



67
68
69
# File 'lib/gitgo/controllers/issue.rb', line 67

def model
  Issue
end

#tagsObject



63
64
65
# File 'lib/gitgo/controllers/issue.rb', line 63

def tags
  repo.index.values('tags')
end