simple_text 0.0.9 → 0.0.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d31dd8cd522df8036941fa8b352c4d454205406c
|
4
|
+
data.tar.gz: a31ab3ff69c1189e89b3d504abc2e8a37cec3556
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b804e4cd009dcf6abdd0c351711a469e9d89c0cfcaba703a3586aa2784667875fdea49b6c6d1302312c5c70cf4aa10196ecaf4f2ca4f02b3345bab6eae4d9257
|
7
|
+
data.tar.gz: 8be57a2b26b7f039a8f460678412f59dd72f5aad4ba262bdf75612dab3b5d5b9a5b4e0f7c3b6f300875d3fcbe6733c73c27c1d169b7e203be99797b222857533
|
@@ -1,65 +1,63 @@
|
|
1
|
-
|
2
|
-
class DocumentsController < ApplicationController
|
1
|
+
class SimpleText::DocumentsController < SimpleText::ApplicationController
|
3
2
|
|
4
|
-
|
5
|
-
|
6
|
-
|
3
|
+
def index
|
4
|
+
@documents = Document.all.page params[:page]
|
5
|
+
end
|
7
6
|
|
8
|
-
|
9
|
-
|
7
|
+
def show
|
8
|
+
@document = Document.where(name: params[:name]).first || not_found
|
10
9
|
|
11
|
-
|
12
|
-
|
13
|
-
end
|
10
|
+
unless fresh_when(etag: @document, last_modified: @document.created_at, public: true)
|
11
|
+
render
|
14
12
|
end
|
13
|
+
end
|
15
14
|
|
16
|
-
|
17
|
-
|
18
|
-
|
15
|
+
def new
|
16
|
+
@document = Document.new
|
17
|
+
end
|
19
18
|
|
20
|
-
|
21
|
-
|
19
|
+
def create
|
20
|
+
@document = Document.create create_params
|
22
21
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
end
|
22
|
+
respond_to do |format|
|
23
|
+
if @document.save
|
24
|
+
create_edit_entry @document, :a_create
|
25
|
+
format.html { redirect_to documents_path, notice: t('simple_text.created') }
|
26
|
+
else
|
27
|
+
format.html { render new_document_path, notice: t('simple_text.error') }
|
30
28
|
end
|
31
29
|
end
|
30
|
+
end
|
32
31
|
|
33
|
-
|
34
|
-
|
35
|
-
|
32
|
+
def edit
|
33
|
+
@document = Document.where(name: params[:id]).first || not_found
|
34
|
+
end
|
36
35
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
end
|
36
|
+
def update
|
37
|
+
@document = Document.where(name: params[:document][:name]).first || not_found
|
38
|
+
_old_doc = @document.clone
|
39
|
+
respond_to do |format|
|
40
|
+
if @document.update permit_params
|
41
|
+
create_edit_entry @document, :a_update, _old_doc.as_json.to_s
|
42
|
+
format.html { redirect_to documents_path, notice: t('simple_text.succeeded') }
|
43
|
+
else
|
44
|
+
format.html { render 'edit' }
|
47
45
|
end
|
48
46
|
end
|
47
|
+
end
|
49
48
|
|
50
|
-
|
51
|
-
|
52
|
-
def permit_params
|
53
|
-
params.require(:document).permit(:title, :contents)
|
54
|
-
end
|
49
|
+
private
|
55
50
|
|
56
|
-
|
57
|
-
|
58
|
-
|
51
|
+
def permit_params
|
52
|
+
params.require(:document).permit(:title, :contents)
|
53
|
+
end
|
59
54
|
|
60
|
-
|
61
|
-
|
62
|
-
|
55
|
+
def create_params
|
56
|
+
params.require(:document).permit(:name, :title, :contents)
|
57
|
+
end
|
63
58
|
|
59
|
+
def not_found
|
60
|
+
raise ActionController::RoutingError.new('Not Found')
|
64
61
|
end
|
65
|
-
|
62
|
+
|
63
|
+
end
|
data/config/routes.rb
CHANGED
data/lib/simple_text/version.rb
CHANGED