appdoc 0.0.1 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
@@ -1,72 +1,58 @@
|
|
1
1
|
class DocumentsController < ApplicationController
|
2
2
|
|
3
|
-
|
3
|
+
respond_to :html
|
4
|
+
respond_to :js, :only => :index
|
5
|
+
|
6
|
+
# Authorization
|
7
|
+
if respond_to? :filter_access_to
|
8
|
+
filter_access_to :all # Devise
|
9
|
+
elsif respond_to? :check_authorization
|
10
|
+
check_authorization # cancan
|
11
|
+
end
|
4
12
|
|
5
|
-
# GET /documents
|
6
13
|
def index
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
@search = Document.tagged_with(params[:tag]).search(params[:search])
|
11
|
-
flash[:warn] = "No documents are tagged with \"#{params[:tag]}\"" if @search.count == 0 and params[:search].nil?
|
12
|
-
end
|
13
|
-
@documents = @search.page(params[:page]).per(20)
|
14
|
+
@documents = Document.named(params[:search])
|
15
|
+
@documents = @documents.tagged_with(params[:tag]) unless params[:tag].blank?
|
16
|
+
@documents = @documents.page(params[:page])
|
14
17
|
|
15
|
-
|
16
|
-
format.html
|
18
|
+
respond_with(@documents) do |format|
|
19
|
+
format.html { flash.now[:alert] = "No documents were found" if @documents.empty? }
|
17
20
|
format.js { render :partial=>'documents' }
|
18
21
|
end
|
19
22
|
end
|
20
23
|
|
21
|
-
# GET /documents/1
|
22
24
|
def show
|
23
|
-
@document = Document.
|
25
|
+
@document = Document.find_by_id_or_slug!(params[:id])
|
24
26
|
end
|
25
27
|
|
26
|
-
# GET /documents/new
|
27
28
|
def new
|
28
29
|
@document = Document.new
|
29
30
|
end
|
30
31
|
|
31
|
-
# GET /documents/1/edit
|
32
32
|
def edit
|
33
|
-
@document = Document.
|
33
|
+
@document = Document.find_by_id_or_slug!(params[:id])
|
34
34
|
end
|
35
35
|
|
36
|
-
# POST /documents
|
37
36
|
def create
|
38
37
|
@document = Document.new(params[:document])
|
39
|
-
|
40
38
|
if @document.save
|
41
39
|
flash[:notice] = 'Document was successfully created.'
|
42
|
-
redirect_to(@document)
|
43
|
-
else
|
44
|
-
render :action => 'new'
|
45
40
|
end
|
41
|
+
respond_with @document
|
46
42
|
end
|
47
43
|
|
48
|
-
# PUT /documents/1
|
49
44
|
def update
|
50
|
-
|
51
|
-
@document = Document.find_by_id(params[:id]) || Document.find_by_slug(params[:id])
|
52
|
-
|
45
|
+
@document = Document.find_by_id_or_slug!(params[:id])
|
53
46
|
if @document.update_attributes(params[:document])
|
54
47
|
flash[:notice] = 'Document was successfully updated.'
|
55
|
-
redirect_to(@document)
|
56
|
-
else
|
57
|
-
render :action => 'edit'
|
58
48
|
end
|
59
|
-
|
49
|
+
respond_with @document
|
60
50
|
end
|
61
51
|
|
62
|
-
# DELETE /documents/1
|
63
52
|
def destroy
|
64
|
-
|
65
|
-
@document = Document.find_by_id(params[:id]) || Document.find_by_slug(params[:id])
|
53
|
+
@document = Document.find_by_id_or_slug!(params[:id])
|
66
54
|
@document.destroy
|
67
|
-
|
68
|
-
redirect_to(documents_url)
|
69
|
-
|
55
|
+
respond_with @document
|
70
56
|
end
|
71
57
|
|
72
58
|
end
|
data/app/models/document.rb
CHANGED
@@ -8,15 +8,25 @@ class Document < ActiveRecord::Base
|
|
8
8
|
|
9
9
|
default_scope :order => 'name'
|
10
10
|
|
11
|
-
scope :named, lambda {|name| select("DISTINCT
|
12
|
-
joins("LEFT OUTER JOIN taggings ON (taggings.taggable_id =
|
11
|
+
scope :named, lambda {|name| select("DISTINCT #{table_name}.*").
|
12
|
+
joins("LEFT OUTER JOIN taggings ON (taggings.taggable_id = #{table_name}.id AND taggings.taggable_type = 'Document')").
|
13
13
|
joins("LEFT OUTER JOIN tags ON taggings.tag_id = tags.id").
|
14
|
-
where("
|
14
|
+
where("#{table_name}.name LIKE ? OR #{table_name}.slug LIKE ? OR tags.name LIKE ?", "%#{name}%", "%#{name}%", "%#{name}%") }
|
15
15
|
|
16
16
|
search_methods :named
|
17
17
|
|
18
18
|
acts_as_taggable
|
19
19
|
|
20
|
+
def self.find_by_id_or_slug(id_or_slug)
|
21
|
+
where("#{table_name}.id = ? OR #{table_name}.slug = ?", id_or_slug, id_or_slug).first
|
22
|
+
end
|
23
|
+
|
24
|
+
def self.find_by_id_or_slug!(id_or_slug)
|
25
|
+
doc = self.find_by_id_or_slug(id_or_slug)
|
26
|
+
raise ActiveRecord::RecordNotFound if doc.nil?
|
27
|
+
doc
|
28
|
+
end
|
29
|
+
|
20
30
|
def to_param
|
21
31
|
self.slug.blank? ? self.id.to_s : self.slug
|
22
32
|
end
|
@@ -1,12 +1,12 @@
|
|
1
1
|
%h2 Documentation
|
2
2
|
|
3
|
-
|
3
|
+
!=form_tag(documents_path, :class => 'search', :method => :get) do
|
4
4
|
!=hidden_field_tag(:tag, params[:tag])
|
5
|
-
!=
|
6
|
-
!=
|
7
|
-
!=
|
5
|
+
!=label_tag(:search, 'Search')
|
6
|
+
!=text_field_tag(:search, params[:search])
|
7
|
+
!=submit_tag('Search')
|
8
8
|
|
9
9
|
.search_results
|
10
|
-
!=render('documents', :documents
|
10
|
+
!=render('documents', :documents => @documents)
|
11
11
|
|
12
12
|
!=render('index_aside')
|
data/lib/appdoc/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: appdoc
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,63 +9,41 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2011-09-
|
12
|
+
date: 2011-09-13 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: acts-as-taggable-on
|
16
|
-
requirement: &
|
16
|
+
requirement: &75343890 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
|
-
- -
|
19
|
+
- - ! '>='
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version: 2.
|
21
|
+
version: 2.0.0
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
25
|
-
- !ruby/object:Gem::Dependency
|
26
|
-
name: declarative_authorization
|
27
|
-
requirement: &73966490 !ruby/object:Gem::Requirement
|
28
|
-
none: false
|
29
|
-
requirements:
|
30
|
-
- - ~>
|
31
|
-
- !ruby/object:Gem::Version
|
32
|
-
version: 0.5.3
|
33
|
-
type: :runtime
|
34
|
-
prerelease: false
|
35
|
-
version_requirements: *73966490
|
24
|
+
version_requirements: *75343890
|
36
25
|
- !ruby/object:Gem::Dependency
|
37
26
|
name: haml
|
38
|
-
requirement: &
|
27
|
+
requirement: &75343630 !ruby/object:Gem::Requirement
|
39
28
|
none: false
|
40
29
|
requirements:
|
41
|
-
- -
|
30
|
+
- - ! '>='
|
42
31
|
- !ruby/object:Gem::Version
|
43
|
-
version: 3.
|
32
|
+
version: 3.0.0
|
44
33
|
type: :runtime
|
45
34
|
prerelease: false
|
46
|
-
version_requirements: *
|
35
|
+
version_requirements: *75343630
|
47
36
|
- !ruby/object:Gem::Dependency
|
48
37
|
name: kaminari
|
49
|
-
requirement: &
|
38
|
+
requirement: &75433740 !ruby/object:Gem::Requirement
|
50
39
|
none: false
|
51
40
|
requirements:
|
52
|
-
- -
|
41
|
+
- - ! '>='
|
53
42
|
- !ruby/object:Gem::Version
|
54
|
-
version: 0.
|
43
|
+
version: 0.10.0
|
55
44
|
type: :runtime
|
56
45
|
prerelease: false
|
57
|
-
version_requirements: *
|
58
|
-
- !ruby/object:Gem::Dependency
|
59
|
-
name: meta_search
|
60
|
-
requirement: &73960980 !ruby/object:Gem::Requirement
|
61
|
-
none: false
|
62
|
-
requirements:
|
63
|
-
- - ~>
|
64
|
-
- !ruby/object:Gem::Version
|
65
|
-
version: 1.0.6
|
66
|
-
type: :runtime
|
67
|
-
prerelease: false
|
68
|
-
version_requirements: *73960980
|
46
|
+
version_requirements: *75433740
|
69
47
|
description: Allows you to add documents and documentation to your app
|
70
48
|
email:
|
71
49
|
- ryan.e.hall@biola.edu
|
@@ -74,23 +52,23 @@ extensions: []
|
|
74
52
|
extra_rdoc_files: []
|
75
53
|
files:
|
76
54
|
- app/models/document.rb
|
77
|
-
- app/views/documents/new.html.haml
|
78
|
-
- app/views/documents/edit.html.haml
|
79
55
|
- app/views/documents/show.html.haml
|
80
|
-
- app/views/documents/
|
56
|
+
- app/views/documents/new.html.haml
|
81
57
|
- app/views/documents/_documents.html.haml
|
82
58
|
- app/views/documents/_form.html.haml
|
59
|
+
- app/views/documents/index.html.haml
|
83
60
|
- app/views/documents/_index_aside.html.haml
|
61
|
+
- app/views/documents/edit.html.haml
|
84
62
|
- app/controllers/documents_controller.rb
|
85
|
-
- lib/appdoc/
|
86
|
-
- lib/appdoc/engine.rb
|
87
|
-
- lib/generators/appdoc/appdoc_generator.rb
|
63
|
+
- lib/generators/appdoc/templates/public/javascripts/SmartTextBox.js
|
88
64
|
- lib/generators/appdoc/templates/public/stylesheets/jquery/smart_text_box/imgs/close.gif
|
89
65
|
- lib/generators/appdoc/templates/public/stylesheets/jquery/smart_text_box/SmartTextBox.css
|
90
|
-
- lib/generators/appdoc/templates/public/javascripts/SmartTextBox.js
|
91
66
|
- lib/generators/appdoc/templates/migration.rb
|
92
67
|
- lib/generators/appdoc/templates/appdoc_config.rb
|
68
|
+
- lib/generators/appdoc/appdoc_generator.rb
|
93
69
|
- lib/appdoc.rb
|
70
|
+
- lib/appdoc/version.rb
|
71
|
+
- lib/appdoc/engine.rb
|
94
72
|
- config/routes.rb
|
95
73
|
homepage: https://github.com/biola/appdoc
|
96
74
|
licenses: []
|
@@ -112,7 +90,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
112
90
|
version: '0'
|
113
91
|
requirements: []
|
114
92
|
rubyforge_project: appdoc
|
115
|
-
rubygems_version: 1.8.
|
93
|
+
rubygems_version: 1.8.7
|
116
94
|
signing_key:
|
117
95
|
specification_version: 3
|
118
96
|
summary: Documentation for your app
|