notee 0.1.0 → 0.2.0

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.
Files changed (106) hide show
  1. checksums.yaml +4 -4
  2. data/MIT-LICENSE +20 -0
  3. data/Rakefile +44 -4
  4. data/app/assets/javascripts/application.js +14 -0
  5. data/app/assets/javascripts/notee/application.js +47366 -0
  6. data/app/assets/stylesheets/notee/application.css +15 -0
  7. data/app/assets/stylesheets/notee/images.css +4 -0
  8. data/app/assets/stylesheets/notee/posts.css +4 -0
  9. data/app/assets/stylesheets/notee/preview.scss +214 -0
  10. data/app/assets/stylesheets/scaffold.css +56 -0
  11. data/app/controllers/notee/application_controller.rb +24 -0
  12. data/app/controllers/notee/categories_controller.rb +55 -0
  13. data/app/controllers/notee/images_controller.rb +48 -0
  14. data/app/controllers/notee/posts_controller.rb +75 -0
  15. data/app/controllers/notee/tokens_controller.rb +30 -0
  16. data/app/helpers/notee/application_helper.rb +4 -0
  17. data/app/helpers/notee/categories_helper.rb +4 -0
  18. data/app/helpers/notee/images_helper.rb +4 -0
  19. data/app/helpers/notee/posts_helper.rb +4 -0
  20. data/app/models/notee/category.rb +4 -0
  21. data/app/models/notee/image.rb +24 -0
  22. data/app/models/notee/post.rb +4 -0
  23. data/app/models/notee/token.rb +18 -0
  24. data/app/views/layouts/notee/application.html.erb +14 -0
  25. data/app/views/notee/posts/notee.html.erb +1 -0
  26. data/app/views/notee/tokens/new.html.erb +5 -0
  27. data/config/routes.rb +12 -0
  28. data/db/migrate/20160605141437_create_notee_posts.rb +29 -0
  29. data/db/migrate/20160605141510_create_notee_categories.rb +15 -0
  30. data/db/migrate/20160605141547_create_notee_images.rb +14 -0
  31. data/db/migrate/20160608102012_create_notee_tokens.rb +12 -0
  32. data/lib/notee.rb +4 -2
  33. data/lib/notee/configuration.rb +28 -0
  34. data/lib/notee/engine.rb +13 -0
  35. data/lib/notee/version.rb +1 -1
  36. data/lib/tasks/notee_tasks.rake +71 -0
  37. data/test/controllers/notee/categories_controller_test.rb +52 -0
  38. data/test/controllers/notee/images_controller_test.rb +52 -0
  39. data/test/controllers/notee/posts_controller_test.rb +52 -0
  40. data/test/dummy/README.rdoc +28 -0
  41. data/test/dummy/Rakefile +6 -0
  42. data/test/dummy/app/assets/javascripts/application.js +13 -0
  43. data/test/dummy/app/assets/stylesheets/application.css +15 -0
  44. data/test/dummy/app/controllers/application_controller.rb +5 -0
  45. data/test/dummy/app/helpers/application_helper.rb +2 -0
  46. data/test/dummy/app/views/layouts/application.html.erb +14 -0
  47. data/test/dummy/bin/bundle +3 -0
  48. data/test/dummy/bin/rails +4 -0
  49. data/test/dummy/bin/rake +4 -0
  50. data/test/dummy/bin/setup +29 -0
  51. data/test/dummy/config.ru +4 -0
  52. data/test/dummy/config/application.rb +26 -0
  53. data/test/dummy/config/boot.rb +5 -0
  54. data/test/dummy/config/database.yml +25 -0
  55. data/test/dummy/config/environment.rb +5 -0
  56. data/test/dummy/config/environments/development.rb +41 -0
  57. data/test/dummy/config/environments/production.rb +79 -0
  58. data/test/dummy/config/environments/test.rb +42 -0
  59. data/test/dummy/config/initializers/assets.rb +11 -0
  60. data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
  61. data/test/dummy/config/initializers/cookies_serializer.rb +3 -0
  62. data/test/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  63. data/test/dummy/config/initializers/inflections.rb +16 -0
  64. data/test/dummy/config/initializers/mime_types.rb +4 -0
  65. data/test/dummy/config/initializers/session_store.rb +3 -0
  66. data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
  67. data/test/dummy/config/locales/en.yml +23 -0
  68. data/test/dummy/config/routes.rb +4 -0
  69. data/test/dummy/config/secrets.yml +23 -0
  70. data/test/dummy/db/development.sqlite3 +0 -0
  71. data/test/dummy/db/schema.rb +16 -0
  72. data/test/dummy/db/test.sqlite3 +0 -0
  73. data/test/dummy/log/development.log +3259 -0
  74. data/test/dummy/public/404.html +67 -0
  75. data/test/dummy/public/422.html +67 -0
  76. data/test/dummy/public/500.html +66 -0
  77. data/test/dummy/public/favicon.ico +0 -0
  78. data/test/fixtures/notee/categories.yml +13 -0
  79. data/test/fixtures/notee/images.yml +7 -0
  80. data/test/fixtures/notee/posts.yml +23 -0
  81. data/test/fixtures/notee/tokens.yml +9 -0
  82. data/test/integration/navigation_test.rb +10 -0
  83. data/test/models/notee/category_test.rb +9 -0
  84. data/test/models/notee/image_test.rb +9 -0
  85. data/test/models/notee/post_test.rb +9 -0
  86. data/test/models/notee/token_test.rb +9 -0
  87. data/test/notee_test.rb +7 -0
  88. data/test/test_helper.rb +20 -0
  89. metadata +195 -33
  90. data/.gitignore +0 -10
  91. data/.idea/.name +0 -1
  92. data/.idea/misc.xml +0 -14
  93. data/.idea/modules.xml +0 -8
  94. data/.idea/notee.iml +0 -17
  95. data/.idea/vcs.xml +0 -6
  96. data/.idea/workspace.xml +0 -335
  97. data/.rspec +0 -2
  98. data/.travis.yml +0 -4
  99. data/CODE_OF_CONDUCT.md +0 -13
  100. data/Gemfile +0 -4
  101. data/LICENSE.txt +0 -21
  102. data/README.md +0 -41
  103. data/bin/console +0 -14
  104. data/bin/setup +0 -7
  105. data/lib/generators/notee/install/install_generator.rb +0 -17
  106. data/notee.gemspec +0 -28
@@ -0,0 +1,15 @@
1
+ /*
2
+ * This is a manifest file that'll be compiled into application.css, which will include all the files
3
+ * listed below.
4
+ *
5
+ * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
6
+ * or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
7
+ *
8
+ * You're free to add application-wide styles to this file and they'll appear at the bottom of the
9
+ * compiled file so the styles you add here take precedence over styles defined in any styles
10
+ * defined in the other CSS/SCSS files in this directory. It is generally better to create a new
11
+ * file per style scope.
12
+ *
13
+ *= require_tree .
14
+ *= require_self
15
+ */
@@ -0,0 +1,4 @@
1
+ /*
2
+ Place all the styles related to the matching controller here.
3
+ They will automatically be included in application.css.
4
+ */
@@ -0,0 +1,4 @@
1
+ /*
2
+ Place all the styles related to the matching controller here.
3
+ They will automatically be included in application.css.
4
+ */
@@ -0,0 +1,214 @@
1
+ /*
2
+ Place all the styles related to the matching controller here.
3
+ They will automatically be included in application.css.
4
+ */
5
+
6
+ #preview{
7
+ img{
8
+ width: 100%;
9
+ }
10
+ }
11
+
12
+
13
+ /*
14
+
15
+ github.com style (c) Vasily Polovnyov <vast@whiteants.net>
16
+
17
+ */
18
+
19
+ .hljs {
20
+ display: block;
21
+ overflow-x: auto;
22
+ padding: 0.5em;
23
+ color: #333;
24
+ background: #f8f8f8;
25
+ }
26
+
27
+ .hljs-comment,
28
+ .hljs-quote {
29
+ color: #998;
30
+ font-style: italic;
31
+ }
32
+
33
+ .hljs-keyword,
34
+ .hljs-selector-tag,
35
+ .hljs-subst {
36
+ color: #333;
37
+ font-weight: bold;
38
+ }
39
+
40
+ .hljs-number,
41
+ .hljs-literal,
42
+ .hljs-variable,
43
+ .hljs-template-variable,
44
+ .hljs-tag .hljs-attr {
45
+ color: #008080;
46
+ }
47
+
48
+ .hljs-string,
49
+ .hljs-doctag {
50
+ color: #d14;
51
+ }
52
+
53
+ .hljs-title,
54
+ .hljs-section,
55
+ .hljs-selector-id {
56
+ color: #900;
57
+ font-weight: bold;
58
+ }
59
+
60
+ .hljs-subst {
61
+ font-weight: normal;
62
+ }
63
+
64
+ .hljs-type,
65
+ .hljs-class .hljs-title {
66
+ color: #458;
67
+ font-weight: bold;
68
+ }
69
+
70
+ .hljs-tag,
71
+ .hljs-name,
72
+ .hljs-attribute {
73
+ color: #000080;
74
+ font-weight: normal;
75
+ }
76
+
77
+ .hljs-regexp,
78
+ .hljs-link {
79
+ color: #009926;
80
+ }
81
+
82
+ .hljs-symbol,
83
+ .hljs-bullet {
84
+ color: #990073;
85
+ }
86
+
87
+ .hljs-built_in,
88
+ .hljs-builtin-name {
89
+ color: #0086b3;
90
+ }
91
+
92
+ .hljs-meta {
93
+ color: #999;
94
+ font-weight: bold;
95
+ }
96
+
97
+ .hljs-deletion {
98
+ background: #fdd;
99
+ }
100
+
101
+ .hljs-addition {
102
+ background: #dfd;
103
+ }
104
+
105
+ .hljs-emphasis {
106
+ font-style: italic;
107
+ }
108
+
109
+ .hljs-strong {
110
+ font-weight: bold;
111
+ }
112
+
113
+ /*
114
+
115
+ vim-hybrid theme by w0ng (https://github.com/w0ng/vim-hybrid)
116
+
117
+ */
118
+
119
+ /*background color*/
120
+ .hljs {
121
+ display: block;
122
+ overflow-x: auto;
123
+ padding: 0.5em;
124
+ background: #1d1f21;
125
+ }
126
+
127
+ /*selection color*/
128
+ .hljs::selection,
129
+ .hljs span::selection {
130
+ background: #373b41;
131
+ }
132
+
133
+ .hljs::-moz-selection,
134
+ .hljs span::-moz-selection {
135
+ background: #373b41;
136
+ }
137
+
138
+ /*foreground color*/
139
+ .hljs {
140
+ color: #c5c8c6;
141
+ }
142
+
143
+ /*color: fg_yellow*/
144
+ .hljs-title,
145
+ .hljs-name {
146
+ color: #f0c674;
147
+ }
148
+
149
+ /*color: fg_comment*/
150
+ .hljs-comment,
151
+ .hljs-meta,
152
+ .hljs-meta .hljs-keyword {
153
+ color: #707880;
154
+ }
155
+
156
+ /*color: fg_red*/
157
+ .hljs-number,
158
+ .hljs-symbol,
159
+ .hljs-literal,
160
+ .hljs-deletion,
161
+ .hljs-link {
162
+ color: #cc6666
163
+ }
164
+
165
+ /*color: fg_green*/
166
+ .hljs-string,
167
+ .hljs-doctag,
168
+ .hljs-addition,
169
+ .hljs-regexp,
170
+ .hljs-selector-attr,
171
+ .hljs-selector-pseudo {
172
+ color: #b5bd68;
173
+ }
174
+
175
+ /*color: fg_purple*/
176
+ .hljs-attribute,
177
+ .hljs-code,
178
+ .hljs-selector-id {
179
+ color: #b294bb;
180
+ }
181
+
182
+ /*color: fg_blue*/
183
+ .hljs-keyword,
184
+ .hljs-selector-tag,
185
+ .hljs-bullet,
186
+ .hljs-tag {
187
+ color: #81a2be;
188
+ }
189
+
190
+ /*color: fg_aqua*/
191
+ .hljs-subst,
192
+ .hljs-variable,
193
+ .hljs-template-tag,
194
+ .hljs-template-variable {
195
+ color: #8abeb7;
196
+ }
197
+
198
+ /*color: fg_orange*/
199
+ .hljs-type,
200
+ .hljs-built_in,
201
+ .hljs-builtin-name,
202
+ .hljs-quote,
203
+ .hljs-section,
204
+ .hljs-selector-class {
205
+ color: #de935f;
206
+ }
207
+
208
+ .hljs-emphasis {
209
+ font-style: italic;
210
+ }
211
+
212
+ .hljs-strong {
213
+ font-weight: bold;
214
+ }
@@ -0,0 +1,56 @@
1
+ body { background-color: #fff; color: #333; }
2
+
3
+ body, p, ol, ul, td {
4
+ font-family: verdana, arial, helvetica, sans-serif;
5
+ font-size: 13px;
6
+ line-height: 18px;
7
+ }
8
+
9
+ pre {
10
+ background-color: #eee;
11
+ padding: 10px;
12
+ font-size: 11px;
13
+ }
14
+
15
+ a { color: #000; }
16
+ a:visited { color: #666; }
17
+ a:hover { color: #fff; background-color:#000; }
18
+
19
+ div.field, div.actions {
20
+ margin-bottom: 10px;
21
+ }
22
+
23
+ #notice {
24
+ color: green;
25
+ }
26
+
27
+ .field_with_errors {
28
+ padding: 2px;
29
+ background-color: red;
30
+ display: table;
31
+ }
32
+
33
+ #error_explanation {
34
+ width: 450px;
35
+ border: 2px solid red;
36
+ padding: 7px;
37
+ padding-bottom: 0;
38
+ margin-bottom: 20px;
39
+ background-color: #f0f0f0;
40
+ }
41
+
42
+ #error_explanation h2 {
43
+ text-align: left;
44
+ font-weight: bold;
45
+ padding: 5px 5px 5px 15px;
46
+ font-size: 12px;
47
+ margin: -7px;
48
+ margin-bottom: 0px;
49
+ background-color: #c00;
50
+ color: #fff;
51
+ }
52
+
53
+ #error_explanation ul li {
54
+ font-size: 12px;
55
+ list-style: square;
56
+ }
@@ -0,0 +1,24 @@
1
+ module Notee
2
+ class ApplicationController < ActionController::Base
3
+
4
+ before_filter :set_access_token
5
+ before_filter :restrict_access_json
6
+
7
+ private
8
+ def set_access_token
9
+ p "TODO: add access_token to http header"
10
+ # request['Authorization: Token token'] = session[:access_token] if session[:access_token].present?
11
+ end
12
+
13
+ def restrict_access_json
14
+ # authenticate_or_request_with_http_token do |token, options|
15
+ # Token.exists?(access_token: token)
16
+ # end
17
+
18
+ unless Token.exists?(access_token: session[:access_token])
19
+ raise
20
+ end
21
+ end
22
+
23
+ end
24
+ end
@@ -0,0 +1,55 @@
1
+
2
+ require_dependency "notee/application_controller"
3
+
4
+ module Notee
5
+ class CategoriesController < ApplicationController
6
+ before_action :set_category, only: [:update, :destroy]
7
+
8
+ def index
9
+ @categories = Category.all
10
+ render json: { status: 'success', categories: @categories}
11
+ end
12
+
13
+ def create
14
+ @category = Category.new(category_params)
15
+ respond_to do |format|
16
+ if @category.save
17
+ format.json { render json: @category, status: 200 }
18
+ else
19
+ format.json { render json: @category.errors, status: :unprocessable_entity }
20
+ end
21
+ end
22
+ end
23
+
24
+ def update
25
+ respond_to do |format|
26
+ if @category.update(category_params)
27
+ format.json { render json: @category, status: 200 }
28
+ else
29
+ format.json { render json: @category.errors, status: :unprocessable_entity }
30
+ end
31
+ end
32
+ end
33
+
34
+ def destroy
35
+ respond_to do |format|
36
+ if @category.destroy
37
+ format.json { render json: @category, status: 200 }
38
+ else
39
+ format.json { render json: @category.errors, status: :internal_server_error }
40
+ end
41
+ end
42
+ end
43
+
44
+ private
45
+
46
+ def category_params
47
+ params.require(:category).permit(:name, :content, :slug, :status, :category_id, :thumbnail_id, :published_at, :seo_keyword, :seo_description)
48
+ end
49
+
50
+ def set_category
51
+ @category = Category.find_by(id: params[:id])
52
+ end
53
+
54
+ end
55
+ end
@@ -0,0 +1,48 @@
1
+
2
+ require_dependency "notee/application_controller"
3
+
4
+ module Notee
5
+ class ImagesController < ApplicationController
6
+
7
+ def index
8
+ @images = Image.all
9
+ render json: { status: 'success', images: @images}
10
+ end
11
+
12
+ def create
13
+
14
+ @image = Image.new
15
+ @image.file = params[:image]
16
+
17
+ respond_to do |format|
18
+ if @image.save
19
+ format.json { render json: @image, status: 200 }
20
+ else
21
+ format.json { render json: @image.errors, status: :unprocessable_entity }
22
+ end
23
+ end
24
+ end
25
+
26
+ def destroy
27
+ return unless @del_img = Image.find_by(content: params[:name])
28
+
29
+ Image.transaction do
30
+ image_dir = Rails.root.to_s + "/public/notee/"
31
+ File.delete(image_dir + @del_img.content)
32
+ respond_to do |format|
33
+ if @del_img.destroy
34
+ format.json { render json: @del_img, status: 200 }
35
+ else
36
+ format.json { render json: @del_img.errors, status: :internal_server_error }
37
+ end
38
+ end
39
+ end
40
+ end
41
+
42
+ private
43
+
44
+ def image_params
45
+ params.require(:image).permit(:title, :content, :slug, :status, :image_id, :thumbnail_id, :published_at, :seo_keyword, :seo_description)
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,75 @@
1
+ require_dependency "notee/application_controller"
2
+
3
+ module Notee
4
+ class PostsController < ApplicationController
5
+
6
+ before_action :set_post, only: [:show, :update, :destroy]
7
+ skip_before_filter :restrict_access_json, only: [:notee]
8
+ before_filter :restrict_access, only: [:notee]
9
+
10
+ def notee
11
+ end
12
+
13
+ # GET /posts
14
+ def index
15
+ @posts = Post.all
16
+ render json: { status: 'success', posts: @posts}
17
+ end
18
+
19
+ # GET /posts/1
20
+ def show
21
+ render json: { status: 'success', post: @post}
22
+ end
23
+
24
+ # POST /posts
25
+ def create
26
+ @post = Post.new(post_params)
27
+ respond_to do |format|
28
+ if @post.save
29
+ format.json { render json: @post, status: 200 }
30
+ else
31
+ format.json { render json: @post.errors, status: :unprocessable_entity }
32
+ end
33
+ end
34
+ end
35
+
36
+ # PATCH/PUT /posts/1
37
+ def update
38
+ respond_to do |format|
39
+ if @post.update(post_params)
40
+ format.json { render json: @post, status: 200 }
41
+ else
42
+ format.json { render json: @post.errors, status: :unprocessable_entity }
43
+ end
44
+ end
45
+ end
46
+
47
+ # DELETE /posts/1
48
+ def destroy
49
+ @post.destroy
50
+ render json: { status: 'success'}
51
+ end
52
+
53
+ private
54
+
55
+ def set_post
56
+ @post = Post.find_by(id: params[:id])
57
+ end
58
+
59
+ # Only allow a trusted parameter "white list" through.
60
+ def post_params
61
+ params.require(:post).permit(:title, :content, :slug, :status, :category_id, :thumbnail_id, :published_at, :seo_keyword, :seo_description)
62
+ end
63
+
64
+ def restrict_access
65
+ # authenticate_or_request_with_http_token do |token, options|
66
+ # Token.exists?(access_token: token)
67
+ # end
68
+
69
+ unless Token.exists?(access_token: session[:access_token])
70
+ redirect_to new_token_path and return
71
+ end
72
+
73
+ end
74
+ end
75
+ end