biovision-post 0.1.180127 → 0.31.200627.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (263) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +79 -13
  3. data/app/assets/config/biovision_post_manifest.js +1 -0
  4. data/app/assets/images/biovision/post/icons/comment.svg +9 -0
  5. data/app/assets/images/biovision/post/icons/time.svg +6 -0
  6. data/app/assets/images/biovision/post/publisher_logo.png +0 -0
  7. data/app/assets/javascripts/biovision/post/biovision-posts.js +251 -0
  8. data/app/assets/stylesheets/biovision/post/admin/posts.scss +101 -0
  9. data/app/assets/stylesheets/biovision/post/posts.scss +94 -37
  10. data/app/controllers/admin/editorial_members_controller.rb +48 -0
  11. data/app/controllers/admin/featured_posts_controller.rb +28 -0
  12. data/app/controllers/admin/post_categories_controller.rb +28 -6
  13. data/app/controllers/admin/post_group_categories_controller.rb +24 -0
  14. data/app/controllers/admin/post_group_tags_controller.rb +24 -0
  15. data/app/controllers/admin/post_groups_controller.rb +67 -0
  16. data/app/controllers/admin/post_illustrations_controller.rb +26 -0
  17. data/app/controllers/admin/post_images_controller.rb +33 -0
  18. data/app/controllers/admin/post_links_controller.rb +19 -0
  19. data/app/controllers/admin/post_tags_controller.rb +35 -0
  20. data/app/controllers/admin/post_types_controller.rb +51 -9
  21. data/app/controllers/admin/posts_controller.rb +29 -7
  22. data/app/controllers/articles_controller.rb +36 -14
  23. data/app/controllers/authors_controller.rb +32 -0
  24. data/app/controllers/blog_posts_controller.rb +36 -14
  25. data/app/controllers/editorial_members_controller.rb +70 -0
  26. data/app/controllers/featured_posts_controller.rb +64 -0
  27. data/app/controllers/my/posts_controller.rb +135 -0
  28. data/app/controllers/news_controller.rb +36 -14
  29. data/app/controllers/post_attachments_controller.rb +31 -0
  30. data/app/controllers/post_categories_controller.rb +12 -17
  31. data/app/controllers/post_groups_controller.rb +81 -0
  32. data/app/controllers/post_illustrations_controller.rb +27 -0
  33. data/app/controllers/post_images_controller.rb +63 -0
  34. data/app/controllers/post_links_controller.rb +40 -0
  35. data/app/controllers/post_tags_controller.rb +46 -0
  36. data/app/controllers/posts_controller.rb +152 -35
  37. data/app/helpers/biovision_posts_helper.rb +134 -24
  38. data/app/jobs/application_job.rb +7 -0
  39. data/app/jobs/post_body_parser_job.rb +15 -0
  40. data/app/models/concerns/post_child_with_priority.rb +50 -0
  41. data/app/models/editorial_member.rb +101 -0
  42. data/app/models/editorial_member_post_type.rb +15 -0
  43. data/app/models/featured_post.rb +25 -0
  44. data/app/models/post.rb +234 -44
  45. data/app/models/post_attachment.rb +48 -0
  46. data/app/models/post_category.rb +81 -53
  47. data/app/models/post_group.rb +84 -0
  48. data/app/models/post_group_category.rb +36 -0
  49. data/app/models/post_group_tag.rb +32 -0
  50. data/app/models/post_illustration.rb +63 -0
  51. data/app/models/post_image.rb +89 -0
  52. data/app/models/post_layout.rb +14 -0
  53. data/app/models/post_link.rb +17 -0
  54. data/app/models/post_note.rb +16 -0
  55. data/app/models/post_post_category.rb +24 -0
  56. data/app/models/post_post_tag.rb +21 -0
  57. data/app/models/post_reference.rb +19 -0
  58. data/app/models/post_tag.rb +70 -0
  59. data/app/models/post_translation.rb +7 -0
  60. data/app/models/post_type.rb +36 -3
  61. data/app/models/post_zen_category.rb +6 -0
  62. data/app/models/zen_category.rb +21 -0
  63. data/app/services/biovision/components/posts_component.rb +134 -0
  64. data/app/services/post_parser.rb +76 -0
  65. data/app/uploaders/post_image_uploader.rb +9 -9
  66. data/app/views/admin/components/links/_posts.html.erb +33 -0
  67. data/app/views/admin/components/user_settings/_posts.html.erb +43 -0
  68. data/app/views/admin/components/user_settings/posts/_post_categories.html.erb +38 -0
  69. data/app/views/admin/editorial_members/_nav_item.html.erb +2 -0
  70. data/app/views/admin/editorial_members/entity/_in_list.html.erb +37 -0
  71. data/app/views/admin/editorial_members/index.html.erb +16 -0
  72. data/app/views/admin/editorial_members/show.html.erb +50 -0
  73. data/app/views/admin/featured_posts/_add.html.erb +140 -0
  74. data/app/views/admin/featured_posts/_language.html.erb +14 -0
  75. data/app/views/admin/featured_posts/_nav_item.html.erb +2 -0
  76. data/app/views/admin/featured_posts/entity/_in_list.html.erb +26 -0
  77. data/app/views/admin/featured_posts/index.html.erb +19 -0
  78. data/app/views/admin/post_attachments/entity/_in_list.html.erb +12 -0
  79. data/app/views/admin/post_categories/entity/_in_list.html.erb +33 -7
  80. data/app/views/admin/post_categories/show.html.erb +19 -3
  81. data/app/views/admin/post_group_categories/entity/_in_list.html.erb +18 -0
  82. data/app/views/admin/post_group_tags/entity/_in_list.html.erb +18 -0
  83. data/app/views/admin/post_groups/_nav_item.html.erb +6 -0
  84. data/app/views/admin/post_groups/entity/_categories.html.erb +33 -0
  85. data/app/views/admin/post_groups/entity/_in_list.html.erb +25 -0
  86. data/app/views/admin/post_groups/index.html.erb +23 -0
  87. data/app/views/admin/post_groups/show.html.erb +66 -0
  88. data/app/views/admin/post_groups/tags.jbuilder +12 -0
  89. data/app/views/admin/post_illustrations/_nav_item.html.erb +6 -0
  90. data/app/views/admin/post_illustrations/entity/_in_list.html.erb +19 -0
  91. data/app/views/admin/post_illustrations/index.html.erb +24 -0
  92. data/app/views/admin/post_illustrations/show.html.erb +33 -0
  93. data/app/views/admin/post_images/_nav_item.html.erb +2 -0
  94. data/app/views/admin/post_images/entity/_in_list.html.erb +30 -0
  95. data/app/views/admin/post_images/index.html.erb +17 -0
  96. data/app/views/admin/post_images/show.html.erb +50 -0
  97. data/app/views/admin/post_links/entity/_in_list.html.erb +43 -0
  98. data/app/views/admin/post_tags/_nav_item.html.erb +2 -0
  99. data/app/views/admin/post_tags/entity/_in_list.html.erb +23 -0
  100. data/app/views/admin/post_tags/index.html.erb +17 -0
  101. data/app/views/admin/post_tags/posts.html.erb +19 -0
  102. data/app/views/admin/post_tags/show.html.erb +38 -0
  103. data/app/views/admin/post_types/authors.html.erb +24 -0
  104. data/app/views/admin/post_types/entity/_in_list.html.erb +1 -1
  105. data/app/views/admin/post_types/index.html.erb +2 -1
  106. data/app/views/admin/post_types/new_post.html.erb +14 -5
  107. data/app/views/admin/post_types/post_categories.html.erb +16 -4
  108. data/app/views/admin/post_types/post_tags.html.erb +19 -0
  109. data/app/views/admin/post_types/show.html.erb +44 -8
  110. data/app/views/admin/posts/_filter.html.erb +19 -0
  111. data/app/views/admin/posts/_nav_item.html.erb +3 -0
  112. data/app/views/admin/posts/_search_form.html.erb +13 -0
  113. data/app/views/admin/posts/entity/_attachments.html.erb +14 -0
  114. data/app/views/admin/posts/entity/_in_list.html.erb +47 -9
  115. data/app/views/admin/posts/entity/_in_search.html.erb +8 -0
  116. data/app/views/admin/posts/entity/_links.html.erb +125 -0
  117. data/app/views/admin/posts/images.html.erb +23 -0
  118. data/app/views/admin/posts/index.html.erb +15 -2
  119. data/app/views/admin/posts/search.html.erb +30 -0
  120. data/app/views/admin/posts/search.jbuilder +26 -0
  121. data/app/views/admin/posts/show.html.erb +124 -23
  122. data/app/views/articles/category.html.erb +10 -10
  123. data/app/views/articles/index.html.erb +12 -9
  124. data/app/views/articles/tagged.html.erb +14 -0
  125. data/app/views/authors/_list.html.erb +18 -0
  126. data/app/views/authors/entity/_in_list.html.erb +9 -0
  127. data/app/views/authors/index.html.erb +10 -0
  128. data/app/views/authors/show.html.erb +31 -0
  129. data/app/views/blog_posts/category.html.erb +10 -10
  130. data/app/views/blog_posts/index.html.erb +15 -10
  131. data/app/views/blog_posts/tagged.html.erb +14 -0
  132. data/app/views/editorial_members/_form.html.erb +86 -0
  133. data/app/views/editorial_members/edit.html.erb +18 -0
  134. data/app/views/editorial_members/new.html.erb +16 -0
  135. data/app/views/featured_posts/create.jbuilder +10 -0
  136. data/app/views/index/dashboard/_biovision_post.html.erb +21 -0
  137. data/app/views/my/index/dashboard/_biovision_post.html.erb +44 -0
  138. data/app/views/my/posts/_form.html.erb +231 -0
  139. data/app/views/my/posts/_list.html.erb +9 -0
  140. data/app/views/my/posts/_post.html.erb +79 -0
  141. data/app/views/my/posts/_preview.html.erb +35 -0
  142. data/app/views/my/posts/articles.html.erb +24 -0
  143. data/app/views/my/posts/blog_posts.html.erb +24 -0
  144. data/app/views/my/posts/edit.html.erb +27 -0
  145. data/app/views/my/posts/index.html.erb +14 -0
  146. data/app/views/my/posts/index/_navigation.html.erb +29 -0
  147. data/app/views/my/posts/new.html.erb +22 -0
  148. data/app/views/my/posts/news_index.html.erb +24 -0
  149. data/app/views/my/posts/show.html.erb +7 -0
  150. data/app/views/news/category.html.erb +10 -10
  151. data/app/views/news/index.html.erb +12 -9
  152. data/app/views/news/tagged.html.erb +14 -0
  153. data/app/views/post_categories/_form.html.erb +82 -43
  154. data/app/views/post_categories/edit.html.erb +1 -1
  155. data/app/views/post_groups/_form.html.erb +79 -0
  156. data/app/views/post_groups/edit.html.erb +17 -0
  157. data/app/views/post_groups/new.html.erb +15 -0
  158. data/app/views/post_groups/show.html.erb +10 -0
  159. data/app/views/post_images/_form.html.erb +121 -0
  160. data/app/views/post_images/edit.html.erb +19 -0
  161. data/app/views/post_images/new.html.erb +18 -0
  162. data/app/views/post_links/create.jbuilder +20 -0
  163. data/app/views/post_tags/_form.html.erb +26 -0
  164. data/app/views/post_tags/edit.html.erb +18 -0
  165. data/app/views/post_tags/new.html.erb +18 -0
  166. data/app/views/posts/_archive_dates.jbuilder +13 -0
  167. data/app/views/posts/_breadcrumbs.html.erb +1 -10
  168. data/app/views/posts/_calendar.html.erb +9 -0
  169. data/app/views/{index/index/_recent_posts.html.erb → posts/_collection.html.erb} +2 -2
  170. data/app/views/posts/_form.html.erb +434 -141
  171. data/app/views/posts/_list.html.erb +1 -1
  172. data/app/views/{blog_posts/index.jbuilder → posts/_list.jbuilder} +3 -3
  173. data/app/views/posts/_post.html.erb +41 -18
  174. data/app/views/posts/_preview.html.erb +38 -21
  175. data/app/views/posts/_search.html.erb +6 -0
  176. data/app/views/posts/_wysiwyg.html.erb +25 -0
  177. data/app/views/posts/archive.jbuilder +3 -0
  178. data/app/views/posts/archive_day.html.erb +12 -0
  179. data/app/views/posts/category.html.erb +18 -0
  180. data/app/views/posts/edit.html.erb +10 -2
  181. data/app/views/posts/entity/_gallery.html.erb +54 -0
  182. data/app/views/posts/entity/_linked_posts.html.erb +7 -0
  183. data/app/views/posts/entity/_metadata.html.erb +38 -11
  184. data/app/views/posts/entity/_publisher.html.erb +3 -1
  185. data/app/views/posts/form/_category_links.html.erb +38 -0
  186. data/app/views/posts/form/_gallery.html.erb +163 -0
  187. data/app/views/posts/index.html.erb +13 -0
  188. data/app/views/posts/index.jbuilder +1 -0
  189. data/app/views/posts/post_type/_category.html.erb +9 -0
  190. data/app/views/posts/post_type/_post_page.html.erb +15 -0
  191. data/app/views/posts/post_type/_posts.html.erb +14 -0
  192. data/app/views/posts/post_type/_tagged.html.erb +7 -0
  193. data/app/views/posts/rss.xml.erb +47 -0
  194. data/app/views/posts/search.html.erb +15 -0
  195. data/app/views/posts/show.html.erb +1 -4
  196. data/app/views/posts/tagged.html.erb +10 -0
  197. data/app/views/posts/tagged.jbuilder +1 -0
  198. data/app/views/posts/zen.xml.erb +42 -0
  199. data/config/locales/posts-en.yml +261 -22
  200. data/config/locales/posts-ru.yml +402 -17
  201. data/config/locales/posts-sv.yml +416 -0
  202. data/config/routes.rb +147 -32
  203. data/db/{migrate → amends}/20180124111113_add_language_to_posts.rb +1 -1
  204. data/db/amends/20180318215555_add_active_to_post_types.rb +11 -0
  205. data/db/amends/20180606120000_add_original_title_to_posts.rb +9 -0
  206. data/db/amends/20180606120001_add_time_required_to_posts.rb +11 -0
  207. data/db/amends/20180611111111_add_pubdate_and_translator_to_posts.rb +19 -0
  208. data/db/amends/20180618111111_add_default_category_name_to_post_types.rb +15 -0
  209. data/db/amends/20180703191919_add_rating_to_posts.rb +14 -0
  210. data/db/amends/20180810111111_add_explicit_to_posts.rb +11 -0
  211. data/db/amends/20180825111111_add_meta_description_to_post_categories.rb +11 -0
  212. data/db/amends/20180927111111_amend_editorial_member_about.rb +13 -0
  213. data/db/amends/20190202232323_add_spam_to_posts.rb +11 -0
  214. data/db/amends/20190224212121_add_data_to_posts.rb +13 -0
  215. data/db/amends/20190224212122_rename_post_image_source.rb +26 -0
  216. data/db/amends/20190224212123_add_uuid_to_post_images.rb +10 -0
  217. data/db/amends/20190313141414_convert_json_post_columns.rb +25 -0
  218. data/db/amends/20190401101010_create_post_illustrations.rb +20 -0
  219. data/db/amends/20190407101010_create_editorial_member_post_types.rb +18 -0
  220. data/db/amends/20190410120000_create_post_groups.rb +47 -0
  221. data/db/amends/20190412191919_add_nav_text_to_post_categories.rb +14 -0
  222. data/db/amends/20190412212121_add_url_part_to_post_types.rb +26 -0
  223. data/db/amends/20190420212121_create_post_layouts.rb +27 -0
  224. data/db/amends/20190424161616_create_post_post_categories.rb +31 -0
  225. data/db/amends/20190925181818_add_search_index_to_posts.rb +24 -0
  226. data/db/migrate/20170930000001_create_post_types.rb +89 -19
  227. data/db/migrate/20170930000010_create_posts.rb +215 -0
  228. data/db/migrate/20180706000000_create_editorial_members.rb +37 -0
  229. data/db/migrate/20180808000000_create_zen_categories.rb +42 -0
  230. data/db/migrate/20190715141414_add_data_to_post_categories.rb +14 -0
  231. data/db/migrate/20190801161616_add_posts_component.rb +14 -0
  232. data/db/migrate/20190822121212_create_post_attachments.rb +20 -0
  233. data/db/migrate/20190914212121_convert_post_privileges.rb +56 -0
  234. data/db/migrate/20191124232323_convert_editorial_privileges.rb +17 -0
  235. data/db/migrate/20200207141414_convert_posts_vote_data.rb +25 -0
  236. data/lib/biovision/post/decorators/controllers/profiles_controller_decorator.rb +9 -0
  237. data/lib/biovision/post/engine.rb +9 -4
  238. data/lib/biovision/post/version.rb +3 -1
  239. data/lib/tasks/posts.rake +6 -0
  240. metadata +191 -58
  241. data/app/assets/images/biovision/post/publisher_logo.svg +0 -3
  242. data/app/services/post_manager.rb +0 -31
  243. data/app/services/post_manager/article_handler.rb +0 -10
  244. data/app/services/post_manager/blog_post_handler.rb +0 -10
  245. data/app/services/post_manager/news_handler.rb +0 -10
  246. data/app/views/admin/index/dashboard/_biovision_post.html.erb +0 -29
  247. data/app/views/admin/index/dashboard/biovision_post/_additional_items.html.erb +0 -0
  248. data/app/views/articles/index.jbuilder +0 -11
  249. data/app/views/articles/show.html.erb +0 -8
  250. data/app/views/blog_posts/show.html.erb +0 -8
  251. data/app/views/news/index.jbuilder +0 -11
  252. data/app/views/news/show.html.erb +0 -8
  253. data/app/views/post_categories/edit.jbuilder +0 -3
  254. data/app/views/post_categories/edit.js.erb +0 -1
  255. data/app/views/post_categories/new.jbuilder +0 -3
  256. data/app/views/post_categories/new.js.erb +0 -1
  257. data/app/views/posts/edit.js.erb +0 -1
  258. data/app/views/posts/form/_wysiwyg.html.erb +0 -14
  259. data/app/views/posts/new.js.erb +0 -1
  260. data/db/migrate/20170930000002_create_post_categories.rb +0 -29
  261. data/db/migrate/20170930000003_create_posts.rb +0 -58
  262. data/db/migrate/20171218111111_add_meta_fields_to_posts.rb +0 -15
  263. data/db/migrate/20171219111112_add_author_fields_to_posts.rb +0 -11
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b889ba7a155e2072f97474ffa415f86b0aaeb387d5266de6f08715ca090dc016
4
- data.tar.gz: b20b223bca477ff0f077720a6102a69dbdd72e68e8b6bbeabb821d632c5296c8
3
+ metadata.gz: b7a3512ea3126ec7b9823f20eb32cc4ada71f998d274bd9c9c054c444f52e70b
4
+ data.tar.gz: 8c50a8202a57385205a5f2fe430ed91bac2063cf3cebf12cb4726cb9d4a24ed9
5
5
  SHA512:
6
- metadata.gz: 9c4e4732cd224dfb38af8e72f881d306bed081a5382fcee710e493b685a87a7c7ba1b8b276660dde410adbfe6529b14a7ac1f2722d91f20e6fb0e52a9b792f81
7
- data.tar.gz: e5f81682ceb25780a39098d3197fe1120b5e70051de31ebffa7b89baba832b771833b4120e127b6d4d117cdc31b8d0ee21ee5d6664b85b2e06bef2e7f95b975d
6
+ metadata.gz: e2ee7bfb1beab756d00a123637c9f8da61b875a56b6957e71f114495f1651a4f8a85559a2fd43f24ee881094dc872f092486d1dedea09ac104a1f9a89491e519
7
+ data.tar.gz: a1779ab2260aed0a7148eb2d26c85149a053c6daff7f52bcc6c00193aa1286c0a22578553f4989cf271b3b9f8c187ec6caedc6afb0f4963184c45fdf26612d75
data/README.md CHANGED
@@ -1,24 +1,90 @@
1
- # Biovision::Post
2
- Short description and motivation.
1
+ Biovision::Post
2
+ ===============
3
3
 
4
- ## Usage
5
- How to use my plugin.
4
+ Модуль публикаций для сайтов на базе `biovision-base`. Используйте на свой
5
+ страх и риск без каких-либо гарантий.
6
6
 
7
- ## Installation
8
- Add this line to your application's Gemfile:
7
+ После запуска `bundle install` не забудьте выполнить
8
+ `rails railties:install:migrations` и `rails db:migrate`.
9
+
10
+ Подключение
11
+ -----------
12
+
13
+ В `Gemfile` добавить использование гема:
14
+
15
+ ```ruby
16
+ gem 'biovision-post', git: 'https://github.com/Biovision/biovision-post.git'
17
+ # gem 'biovision-post', path: '/Users/maxim/Projects/Biovision/gems/biovision-post'
18
+ ```
19
+
20
+ Если нужен elasticsearch для поиска
21
+ -----------------------------------
22
+
23
+ В `Gemfile` добавить Elastic:
9
24
 
10
25
  ```ruby
11
- gem 'biovision-post'
26
+ gem 'elasticsearch-model', '~> 5.1'
27
+ gem 'elasticsearch-persistence'
12
28
  ```
13
29
 
14
- And then execute:
15
- ```bash
16
- $ bundle
30
+ Версия `elasticsearch-model` должна соответствовать версии elasticsearch
31
+ на сервере, поэтому имеет смысл указать её явно.
32
+
33
+ В конфигурацию приложения (например, в `config/initializers/biovision.rb`) нужно
34
+ добавить название индекса:
35
+
36
+ ```ruby
37
+ config.post_index_name = 'example_post'
38
+ ```
39
+
40
+ Подключение фронтовой части
41
+ ---------------------------
42
+
43
+ Добавить в `config/initializers/assets.rb`:
44
+
45
+ ```ruby
46
+ Rails.application.config.assets.precompile << %w[biovision/post/*]
17
47
  ```
18
48
 
19
- Or install it yourself as:
20
- ```bash
21
- $ gem install biovision-post
49
+ Добавить в `app/assets/javascripts/application.js`:
50
+
51
+ ```js
52
+ //= require biovision/post/biovision-posts
53
+ ```
54
+
55
+ Добавить в `app/assets/stylesheets/application.scss`, если нужна стилизация
56
+ «из коробки».
57
+
58
+ ```scss
59
+ @import "biovision/post/posts";
60
+ ```
61
+
62
+ Добавить в `app/assets/stylesheets/admin.scss` для стилизации административной
63
+ части модуля.
64
+
65
+ ```scss
66
+ @import "biovision/post/admin/posts";
67
+ ```
68
+
69
+ Микроразметка и Publisher Logo
70
+ ------------------------------
71
+
72
+ При выводе публикаций используется разметка `schema.org`, в том числе параметр
73
+ publisher logo, картинка для которого находится в
74
+ `app/assets/images/biovision/post/publisher_logo.png`.
75
+
76
+ Сам шаблон, где выводятся соответствующие данные, находится в
77
+ `app/views/posts/entity/_publisher.html.erb`.
78
+
79
+ «Охлаждение» рейтинга публикаций
80
+ --------------------------------
81
+
82
+ Для уменьшения по модулю рейтинга публикаций на 10 процентов есть задача
83
+ `posts:cooldown`. Можно добавить запуск в cron, чтобы она запускалась
84
+ регулярно.
85
+
86
+ ```cron
87
+ 30 3 * * * cd /var/www/example.com/current && /home/developer/.rbenv/shims/bundle exec rails RAILS_ENV=production posts:cooldown
22
88
  ```
23
89
 
24
90
  ## Contributing
@@ -1,2 +1,3 @@
1
+ //= link_tree ../images
1
2
  //= link_directory ../javascripts/biovision/post .js
2
3
  //= link_directory ../stylesheets/biovision/post .css
@@ -0,0 +1,9 @@
1
+ <svg version="1.1" viewBox="0 0 24 24" width="24px" height="24px" xmlns="http://www.w3.org/2000/svg">
2
+ <title>Comment</title>
3
+ <defs>
4
+ <style type="text/css">
5
+ path { fill: #fff; stroke: #000; stroke-width: 1; stroke-linejoin: round}
6
+ </style>
7
+ </defs>
8
+ <path d="M16,21 v-3 h3 a3,3 0 0,0 3,-3 v-7 a3,3 0 0,0 -3,-3 h-14 a3,3 0 0,0 -3,3 v7 a3,3 0 0,0, 3,3 h8 z"/>
9
+ </svg>
@@ -0,0 +1,6 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="24px" height="24px">
2
+ <g>
3
+ <circle cx="12" cy="12" r="11" stroke-width="1" stroke="#000000" fill="none"/>
4
+ <path d="M 12,4 v 8 h 6" stroke-width="1" fill="none" stroke="#000000" />
5
+ </g>
6
+ </svg>
@@ -0,0 +1,251 @@
1
+ "use strict";
2
+
3
+ const Posts = {
4
+ initialized: false,
5
+ autoInitComponents: true,
6
+ components: {}
7
+ };
8
+
9
+ Posts.components.postLoader = {
10
+ initialized: false,
11
+ buttons: [],
12
+ selector: ".posts-loader",
13
+ init: function () {
14
+ document.querySelectorAll(this.selector).forEach(this.apply);
15
+ this.initialized = true;
16
+ },
17
+ apply: function (button) {
18
+ const component = Posts.components.postLoader;
19
+ component.buttons.push(button);
20
+ button.addEventListener("click", component.handler);
21
+ },
22
+ handler: function (e) {
23
+ e.preventDefault();
24
+
25
+ const button = e.target;
26
+ const container = document.getElementById(button.getAttribute('data-container'));
27
+ if (container) {
28
+ const list = container.querySelector("div.posts-list");
29
+
30
+ if (list && !button.classList.contains('loading')) {
31
+ const url = button.getAttribute('href');
32
+ const request = Biovision.jsonAjaxRequest("get", url, function () {
33
+ button.classList.remove('loading');
34
+
35
+ const response = JSON.parse(this.responseText);
36
+ let nextLink;
37
+ if (response.hasOwnProperty('data')) {
38
+ response.data.forEach(function (element) {
39
+ if (element.hasOwnProperty('meta')) {
40
+ list.insertAdjacentHTML('beforeEnd', element.meta['html_preview']);
41
+ }
42
+ });
43
+ }
44
+ if (response.hasOwnProperty('links')) {
45
+ const links = response.links;
46
+ if (links.hasOwnProperty('next')) {
47
+ nextLink = links.next;
48
+ }
49
+ }
50
+ if (nextLink) {
51
+ button.setAttribute('href', nextLink);
52
+ } else {
53
+ button.classList.add('hidden');
54
+ }
55
+ });
56
+
57
+ button.classList.add('loading');
58
+ request.send();
59
+ }
60
+ } else {
61
+ console.log("Cannot find container for loaded posts");
62
+ }
63
+ }
64
+ };
65
+
66
+ Posts.components.calendar = {
67
+ initialized: false,
68
+ element: undefined,
69
+ dates: [],
70
+ current: 0,
71
+ buttons: {},
72
+ header: undefined,
73
+ days: undefined,
74
+ init: function () {
75
+ this.element = document.getElementById('posts-calendar');
76
+ if (this.element) {
77
+ const component = this;
78
+ const url = this.element.getAttribute('data-url');
79
+ const request = Biovision.newAjaxRequest('get', url, function () {
80
+ const response = JSON.parse(this.responseText);
81
+ if (response.hasOwnProperty('meta')) {
82
+ const meta = response['meta'];
83
+ if (meta.hasOwnProperty('dates')) {
84
+ meta.dates.forEach(function (years) {
85
+ const year = years['year'];
86
+ if (years.hasOwnProperty('months')) {
87
+ years['months'].forEach(function (months) {
88
+ if (months['days']) {
89
+ const days = {};
90
+ months["days"].forEach(function (d) {
91
+ days[d["day"]] = d["path"];
92
+ });
93
+ component.dates.push({
94
+ "year": year,
95
+ "month": months["month"],
96
+ "text": months["name"] + ' ' + year,
97
+ "days": days
98
+ })
99
+ }
100
+ });
101
+ }
102
+ });
103
+
104
+ component.select(component.dates.length - 1);
105
+ }
106
+ }
107
+ });
108
+ request.send();
109
+
110
+ this.buttons["prev"] = this.element.querySelector('button.prev');
111
+ this.buttons["next"] = this.element.querySelector('button.next');
112
+ this.buttons["prev"].addEventListener('click', this.buttonClick);
113
+ this.buttons["next"].addEventListener('click', this.buttonClick);
114
+ this.header = this.element.querySelector('.header span');
115
+ this.days = this.element.querySelector('.days');
116
+
117
+ this.initialized = true;
118
+ }
119
+ },
120
+ select: function (number) {
121
+ const component = Posts.components.calendar;
122
+ if (number < 0 || number >= component.dates.length) {
123
+ return;
124
+ }
125
+ component.current = number;
126
+ if (number > 0) {
127
+ component.buttons["prev"].setAttribute('data-number', number - 1);
128
+ component.buttons["prev"].disabled = false;
129
+ } else {
130
+ component.buttons["prev"].disabled = true;
131
+ }
132
+ if (number < component.dates.length - 1) {
133
+ component.buttons["next"].setAttribute('data-number', number + 1);
134
+ component.buttons["next"].disabled = false;
135
+ } else {
136
+ component.buttons["next"].disabled = true;
137
+ }
138
+ const item = component.dates[number];
139
+
140
+ /**
141
+ * Month number starts from 0, so we use the next month and day 0
142
+ * to get the last day of actual month
143
+ *
144
+ * @type {number}
145
+ */
146
+ const dayCount = new Date(item["year"], item["month"], 0).getDate();
147
+ const dayNumber = new Date(item["year"], item["month"] - 1, 1).getDay();
148
+ component.header.innerHTML = item["text"];
149
+ component.days.innerHTML = "";
150
+ let buffer = "";
151
+ let style = "";
152
+ for (let d = 1; d <= dayCount; d++) {
153
+ if (d === 1 && dayNumber !== 1) {
154
+ style = ' style="margin-left:calc(100% / 7 * ';
155
+ style += (dayNumber > 0) ? (dayNumber - 1) : 6;
156
+ style += ')"';
157
+ } else {
158
+ style = "";
159
+ }
160
+ buffer += '<div' + style + '><span>';
161
+ if (item.days[d]) {
162
+ buffer += '<a href="' + item.days[d] + '">' + d + '</a>';
163
+ } else {
164
+ buffer += d;
165
+ }
166
+ buffer += '</span></div>';
167
+ }
168
+ component.days.innerHTML = buffer;
169
+ },
170
+ buttonClick: function (event) {
171
+ const button = event.target;
172
+ const number = parseInt(button.getAttribute("data-number"));
173
+ Posts.components.calendar.select(number);
174
+ }
175
+ };
176
+
177
+ Posts.components.groupTagLinker = {
178
+ initialized: false,
179
+ container: undefined,
180
+ input: undefined,
181
+ list: document.createElement("ul"),
182
+ init: function () {
183
+ this.input = document.getElementById("tag-search");
184
+ if (this.input) {
185
+ this.container = this.input.parentNode.querySelector(".list-container");
186
+
187
+ if (this.container) {
188
+ const component = this;
189
+ this.list.classList.add('entity-links');
190
+ this.input.addEventListener("change", component.handler);
191
+ this.container.append(this.list);
192
+ this.initialized = true;
193
+ } else {
194
+ console.log("Cannot find container for tags list")
195
+ }
196
+ }
197
+ },
198
+ /**
199
+ * @type {Function}
200
+ */
201
+ handler: function () {
202
+ const component = Posts.components.groupTagLinker;
203
+ const query = "?q=" + encodeURIComponent(component.input.value);
204
+ const url = component.input.getAttribute('data-url') + query;
205
+
206
+ Biovision.jsonAjaxRequest("GET", url, component.parseResponse).send();
207
+ },
208
+ /**
209
+ * @type {Function}
210
+ */
211
+ parseResponse: function () {
212
+ const response = JSON.parse(this.responseText);
213
+
214
+ if (response.hasOwnProperty("data")) {
215
+ const component = Posts.components.groupTagLinker;
216
+ component.list.innerHTML = '';
217
+ response.data.forEach(component.process);
218
+ }
219
+ },
220
+ /**
221
+ *
222
+ * @type {Function}
223
+ * @param data
224
+ */
225
+ process: function (data) {
226
+ const component = Posts.components.groupTagLinker;
227
+ if (data.hasOwnProperty("meta")) {
228
+ const meta = data.meta;
229
+ const li = document.createElement('li');
230
+ const input = document.createElement('input');
231
+ const label = document.createElement('label');
232
+ const element_id = "post_tag_" + data["id"];
233
+
234
+ Biovision.components.entityLinker.apply(input);
235
+
236
+ input.setAttribute("type", "checkbox");
237
+ input.setAttribute("id", element_id);
238
+ input.setAttribute("data-url", meta["url"]);
239
+ input.checked = meta["checked"];
240
+ li.append(input);
241
+
242
+ label.setAttribute("for", element_id);
243
+ label.innerHTML = data.attributes["name"] + " (" + meta["post_type"] + ")";
244
+ li.append(label);
245
+
246
+ component.list.append(li);
247
+ }
248
+ }
249
+ };
250
+
251
+ Biovision.components.posts = Posts;
@@ -0,0 +1,101 @@
1
+ .post-in-search {
2
+ display: flex;
3
+
4
+ img {
5
+ max-width: 100%;
6
+ }
7
+
8
+ .image {
9
+ flex: none;
10
+ margin-right: .4rem;
11
+ width: 8rem;
12
+ }
13
+
14
+ .data {
15
+ flex: 1;
16
+ }
17
+
18
+ .title {
19
+ font-size: var(--font-size-increased, 1.8rem);
20
+ font-weight: 500;
21
+ }
22
+
23
+ .type {
24
+ color: var(--text-color-secondary, #777);
25
+ font-size: var(--font-size-decreased, 1.4rem);
26
+ }
27
+
28
+ .author {
29
+ font-size: var(--font-size-decreased, 1.4rem);
30
+ }
31
+ }
32
+
33
+ #featured-post-search,
34
+ #post-link-search {
35
+ margin-top: var(--spacer-small, 3.2rem);
36
+
37
+ .results {
38
+ > div {
39
+ align-items: flex-start;
40
+ border-bottom: .1rem dotted;
41
+ display: flex;
42
+ padding: .4rem;
43
+ }
44
+
45
+ button {
46
+ flex: none;
47
+ margin: 0 .4rem 0 0;
48
+ }
49
+ }
50
+ }
51
+
52
+ .post-form-gallery {
53
+ margin: var(--spacer-small, 3.2rem) 0;
54
+
55
+ .field {
56
+ input,
57
+ textarea {
58
+ width: 100%;
59
+ }
60
+ }
61
+ }
62
+
63
+ #post-form {
64
+ .loading_message {
65
+ border: .1rem solid #777;
66
+ margin: var(--spacer-s, 1.6rem) 0;
67
+ padding: var(--spacer-s, 1.6rem);
68
+ }
69
+
70
+ progress {
71
+ width: 100%;
72
+ }
73
+ }
74
+
75
+ #post_translation {
76
+ &:not(:checked) ~ div {
77
+ opacity: .25;
78
+ }
79
+
80
+ ~ div {
81
+ margin-left: 2.2rem;
82
+ transition: opacity .25s;
83
+ }
84
+ }
85
+
86
+ .post-category-tree {
87
+ .post-category-tree {
88
+ border-left: .1rem solid #eee;
89
+ margin-bottom: var(--spacer-xs);
90
+ margin-left: .8rem;
91
+ padding-left: 1rem;
92
+ }
93
+ }
94
+
95
+ .biovision-post-type-flag {
96
+ &:not(:checked) {
97
+ ~ ul {
98
+ display: none;
99
+ }
100
+ }
101
+ }