biovision-post 0.2.180325 → 0.21.190513.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (236) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +79 -13
  3. data/app/assets/images/biovision/post/icons/time.svg +6 -0
  4. data/app/assets/images/biovision/post/publisher_logo.png +0 -0
  5. data/app/assets/javascripts/biovision/post/biovision-posts.js +258 -0
  6. data/app/assets/stylesheets/biovision/post/admin/posts.scss +93 -0
  7. data/app/assets/stylesheets/biovision/post/posts.scss +88 -37
  8. data/app/controllers/admin/editorial_members_controller.rb +43 -0
  9. data/app/controllers/admin/featured_posts_controller.rb +23 -0
  10. data/app/controllers/admin/post_group_categories_controller.rb +19 -0
  11. data/app/controllers/admin/post_group_tags_controller.rb +19 -0
  12. data/app/controllers/admin/post_groups_controller.rb +62 -0
  13. data/app/controllers/admin/post_illustrations_controller.rb +26 -0
  14. data/app/controllers/admin/post_images_controller.rb +33 -0
  15. data/app/controllers/admin/post_links_controller.rb +19 -0
  16. data/app/controllers/admin/post_tags_controller.rb +30 -0
  17. data/app/controllers/admin/post_types_controller.rb +16 -4
  18. data/app/controllers/admin/posts_controller.rb +26 -2
  19. data/app/controllers/articles_controller.rb +23 -11
  20. data/app/controllers/authors_controller.rb +27 -0
  21. data/app/controllers/blog_posts_controller.rb +23 -11
  22. data/app/controllers/editorial_members_controller.rb +65 -0
  23. data/app/controllers/featured_posts_controller.rb +59 -0
  24. data/app/controllers/my/posts_controller.rb +124 -0
  25. data/app/controllers/news_controller.rb +23 -11
  26. data/app/controllers/post_categories_controller.rb +4 -14
  27. data/app/controllers/post_groups_controller.rb +76 -0
  28. data/app/controllers/post_illustrations_controller.rb +22 -0
  29. data/app/controllers/post_images_controller.rb +62 -0
  30. data/app/controllers/post_links_controller.rb +37 -0
  31. data/app/controllers/post_tags_controller.rb +41 -0
  32. data/app/controllers/posts_controller.rb +119 -14
  33. data/app/helpers/biovision_posts_helper.rb +114 -5
  34. data/app/jobs/application_job.rb +7 -0
  35. data/app/jobs/post_body_parser_job.rb +15 -0
  36. data/app/models/editorial_member.rb +92 -0
  37. data/app/models/editorial_member_post_type.rb +15 -0
  38. data/app/models/featured_post.rb +25 -0
  39. data/app/models/post.rb +203 -38
  40. data/app/models/post_category.rb +76 -54
  41. data/app/models/post_group.rb +84 -0
  42. data/app/models/post_group_category.rb +36 -0
  43. data/app/models/post_group_tag.rb +32 -0
  44. data/app/models/post_illustration.rb +62 -0
  45. data/app/models/post_image.rb +88 -0
  46. data/app/models/post_layout.rb +14 -0
  47. data/app/models/post_link.rb +2 -0
  48. data/app/models/post_post_category.rb +24 -0
  49. data/app/models/post_post_tag.rb +21 -0
  50. data/app/models/post_tag.rb +70 -0
  51. data/app/models/post_translation.rb +7 -0
  52. data/app/models/post_type.rb +18 -2
  53. data/app/models/post_zen_category.rb +6 -0
  54. data/app/models/zen_category.rb +21 -0
  55. data/app/services/post_manager.rb +52 -15
  56. data/app/services/post_parser.rb +80 -0
  57. data/app/uploaders/post_image_uploader.rb +9 -9
  58. data/app/views/admin/editorial_members/_nav_item.html.erb +2 -0
  59. data/app/views/admin/editorial_members/entity/_in_list.html.erb +37 -0
  60. data/app/views/admin/editorial_members/index.html.erb +15 -0
  61. data/app/views/admin/editorial_members/show.html.erb +71 -0
  62. data/app/views/admin/featured_posts/_add.html.erb +140 -0
  63. data/app/views/admin/featured_posts/_language.html.erb +14 -0
  64. data/app/views/admin/featured_posts/_nav_item.html.erb +2 -0
  65. data/app/views/admin/featured_posts/entity/_in_list.html.erb +26 -0
  66. data/app/views/admin/featured_posts/index.html.erb +18 -0
  67. data/app/views/admin/index/dashboard/_biovision_post.html.erb +32 -25
  68. data/app/views/admin/post_categories/entity/_in_list.html.erb +22 -6
  69. data/app/views/admin/post_categories/show.html.erb +6 -1
  70. data/app/views/admin/post_group_categories/entity/_in_list.html.erb +18 -0
  71. data/app/views/admin/post_group_tags/entity/_in_list.html.erb +18 -0
  72. data/app/views/admin/post_groups/_nav_item.html.erb +6 -0
  73. data/app/views/admin/post_groups/entity/_categories.html.erb +33 -0
  74. data/app/views/admin/post_groups/entity/_in_list.html.erb +25 -0
  75. data/app/views/admin/post_groups/index.html.erb +22 -0
  76. data/app/views/admin/post_groups/show.html.erb +65 -0
  77. data/app/views/admin/post_groups/tags.jbuilder +12 -0
  78. data/app/views/admin/post_illustrations/_nav_item.html.erb +6 -0
  79. data/app/views/admin/post_illustrations/entity/_in_list.html.erb +19 -0
  80. data/app/views/admin/post_illustrations/index.html.erb +23 -0
  81. data/app/views/admin/post_illustrations/show.html.erb +32 -0
  82. data/app/views/admin/post_images/_nav_item.html.erb +2 -0
  83. data/app/views/admin/post_images/entity/_in_list.html.erb +30 -0
  84. data/app/views/admin/post_images/index.html.erb +16 -0
  85. data/app/views/admin/post_images/show.html.erb +49 -0
  86. data/app/views/admin/post_links/entity/_in_list.html.erb +43 -0
  87. data/app/views/admin/post_tags/_nav_item.html.erb +2 -0
  88. data/app/views/admin/post_tags/entity/_in_list.html.erb +23 -0
  89. data/app/views/admin/post_tags/index.html.erb +16 -0
  90. data/app/views/admin/post_tags/posts.html.erb +18 -0
  91. data/app/views/admin/post_tags/show.html.erb +37 -0
  92. data/app/views/admin/post_types/authors.html.erb +23 -0
  93. data/app/views/admin/post_types/post_categories.html.erb +15 -4
  94. data/app/views/admin/post_types/post_tags.html.erb +18 -0
  95. data/app/views/admin/post_types/show.html.erb +28 -5
  96. data/app/views/admin/posts/_filter.html.erb +19 -0
  97. data/app/views/admin/posts/_nav_item.html.erb +3 -0
  98. data/app/views/admin/posts/_search_form.html.erb +13 -0
  99. data/app/views/admin/posts/entity/_in_list.html.erb +31 -7
  100. data/app/views/admin/posts/entity/_in_search.html.erb +8 -0
  101. data/app/views/admin/posts/entity/_links.html.erb +125 -0
  102. data/app/views/admin/posts/images.html.erb +22 -0
  103. data/app/views/admin/posts/index.html.erb +4 -0
  104. data/app/views/admin/posts/search.html.erb +21 -0
  105. data/app/views/admin/posts/search.jbuilder +26 -0
  106. data/app/views/admin/posts/show.html.erb +118 -18
  107. data/app/views/articles/category.html.erb +9 -9
  108. data/app/views/articles/index.html.erb +12 -9
  109. data/app/views/articles/show.html.erb +2 -4
  110. data/app/views/articles/tagged.html.erb +14 -0
  111. data/app/views/authors/_list.html.erb +18 -0
  112. data/app/views/authors/entity/_in_list.html.erb +9 -0
  113. data/app/views/authors/index.html.erb +10 -0
  114. data/app/views/authors/show.html.erb +31 -0
  115. data/app/views/blog_posts/category.html.erb +9 -9
  116. data/app/views/blog_posts/index.html.erb +12 -9
  117. data/app/views/blog_posts/show.html.erb +2 -4
  118. data/app/views/blog_posts/tagged.html.erb +14 -0
  119. data/app/views/editorial_members/_form.html.erb +107 -0
  120. data/app/views/editorial_members/edit.html.erb +17 -0
  121. data/app/views/editorial_members/new.html.erb +15 -0
  122. data/app/views/featured_posts/create.jbuilder +10 -0
  123. data/app/views/index/dashboard/_biovision_post.html.erb +18 -2
  124. data/app/views/my/index/dashboard/_biovision_post.html.erb +43 -0
  125. data/app/views/my/posts/_form.html.erb +357 -0
  126. data/app/views/my/posts/_list.html.erb +9 -0
  127. data/app/views/my/posts/_post.html.erb +80 -0
  128. data/app/views/my/posts/_preview.html.erb +35 -0
  129. data/app/views/my/posts/articles.html.erb +24 -0
  130. data/app/views/my/posts/blog_posts.html.erb +24 -0
  131. data/app/views/my/posts/edit.html.erb +19 -0
  132. data/app/views/my/posts/index.html.erb +14 -0
  133. data/app/views/my/posts/index/_navigation.html.erb +29 -0
  134. data/app/views/my/posts/new.html.erb +14 -0
  135. data/app/views/my/posts/news_index.html.erb +24 -0
  136. data/app/views/my/posts/show.html.erb +7 -0
  137. data/app/views/news/category.html.erb +9 -9
  138. data/app/views/news/index.html.erb +12 -9
  139. data/app/views/news/show.html.erb +2 -4
  140. data/app/views/news/tagged.html.erb +14 -0
  141. data/app/views/post_categories/_form.html.erb +82 -43
  142. data/app/views/post_groups/_form.html.erb +79 -0
  143. data/app/views/post_groups/edit.html.erb +17 -0
  144. data/app/views/post_groups/new.html.erb +15 -0
  145. data/app/views/post_groups/show.html.erb +10 -0
  146. data/app/views/post_images/_form.html.erb +121 -0
  147. data/app/views/post_images/edit.html.erb +19 -0
  148. data/app/views/post_images/new.html.erb +18 -0
  149. data/app/views/post_links/create.jbuilder +20 -0
  150. data/app/views/post_tags/_form.html.erb +26 -0
  151. data/app/views/post_tags/edit.html.erb +18 -0
  152. data/app/views/post_tags/new.html.erb +18 -0
  153. data/app/views/posts/_archive_dates.jbuilder +13 -0
  154. data/app/views/posts/_breadcrumbs.html.erb +4 -8
  155. data/app/views/posts/_calendar.html.erb +9 -0
  156. data/app/views/posts/_collection.html.erb +5 -0
  157. data/app/views/posts/_form.html.erb +204 -64
  158. data/app/views/posts/_list.html.erb +1 -1
  159. data/app/views/{articles/index.jbuilder → posts/_list.jbuilder} +3 -3
  160. data/app/views/posts/_post.html.erb +43 -16
  161. data/app/views/posts/_preview.html.erb +32 -21
  162. data/app/views/posts/_search.html.erb +6 -0
  163. data/app/views/posts/_wysiwyg.html.erb +25 -0
  164. data/app/views/posts/archive.jbuilder +3 -0
  165. data/app/views/posts/archive_day.html.erb +12 -0
  166. data/app/views/posts/category.html.erb +18 -0
  167. data/app/views/posts/entity/_gallery.html.erb +54 -0
  168. data/app/views/posts/entity/_linked_posts.html.erb +7 -0
  169. data/app/views/posts/entity/_metadata.html.erb +35 -12
  170. data/app/views/posts/entity/_publisher.html.erb +3 -1
  171. data/app/views/posts/form/_category_links.html.erb +32 -0
  172. data/app/views/posts/form/_gallery.html.erb +163 -0
  173. data/app/views/posts/index.html.erb +13 -0
  174. data/app/views/posts/index.jbuilder +1 -0
  175. data/app/views/posts/post_type/_category.html.erb +7 -0
  176. data/app/views/posts/post_type/_post_page.html.erb +9 -0
  177. data/app/views/posts/post_type/_posts.html.erb +5 -0
  178. data/app/views/posts/post_type/_tagged.html.erb +7 -0
  179. data/app/views/posts/rss.xml.erb +47 -0
  180. data/app/views/posts/search.html.erb +15 -0
  181. data/app/views/posts/show.html.erb +5 -3
  182. data/app/views/posts/tagged.html.erb +10 -0
  183. data/app/views/posts/tagged.jbuilder +1 -0
  184. data/app/views/posts/zen.xml.erb +42 -0
  185. data/config/locales/posts-en.yml +257 -19
  186. data/config/locales/posts-ru.yml +380 -14
  187. data/config/locales/posts-sv.yml +416 -0
  188. data/config/routes.rb +111 -15
  189. data/db/{migrate → amends}/20180124111113_add_language_to_posts.rb +0 -0
  190. data/db/{migrate → amends}/20180318215555_add_active_to_post_types.rb +0 -0
  191. data/db/amends/20180606120000_add_original_title_to_posts.rb +9 -0
  192. data/db/amends/20180606120001_add_time_required_to_posts.rb +11 -0
  193. data/db/amends/20180611111111_add_pubdate_and_translator_to_posts.rb +19 -0
  194. data/db/amends/20180618111111_add_default_category_name_to_post_types.rb +15 -0
  195. data/db/amends/20180703191919_add_rating_to_posts.rb +14 -0
  196. data/db/amends/20180810111111_add_explicit_to_posts.rb +11 -0
  197. data/db/amends/20180825111111_add_meta_description_to_post_categories.rb +11 -0
  198. data/db/amends/20180927111111_amend_editorial_member_about.rb +13 -0
  199. data/db/migrate/20170930000001_create_post_types.rb +98 -20
  200. data/db/migrate/20170930000010_create_posts.rb +194 -0
  201. data/db/migrate/20180706000000_create_editorial_members.rb +37 -0
  202. data/db/migrate/20180808000000_create_zen_categories.rb +42 -0
  203. data/db/migrate/20190202232323_add_spam_to_posts.rb +11 -0
  204. data/db/migrate/20190224212121_add_data_to_posts.rb +13 -0
  205. data/db/migrate/20190224212122_rename_post_image_source.rb +26 -0
  206. data/db/migrate/20190224212123_add_uuid_to_post_images.rb +10 -0
  207. data/db/migrate/20190313141414_convert_json_post_columns.rb +25 -0
  208. data/db/migrate/20190401101010_create_post_illustrations.rb +20 -0
  209. data/db/migrate/20190407101010_create_editorial_member_post_types.rb +18 -0
  210. data/db/migrate/20190410101010_add_avoid_parsing_to_posts.rb +14 -0
  211. data/db/migrate/20190410120000_create_post_groups.rb +47 -0
  212. data/db/migrate/20190412191919_add_nav_text_to_post_categories.rb +14 -0
  213. data/db/migrate/20190412212121_add_url_part_to_post_types.rb +26 -0
  214. data/db/migrate/20190420212121_create_post_layouts.rb +27 -0
  215. data/db/migrate/20190424161616_create_post_post_categories.rb +31 -0
  216. data/lib/biovision/post/version.rb +3 -1
  217. data/lib/tasks/posts.rake +6 -0
  218. metadata +170 -25
  219. data/app/assets/images/biovision/post/publisher_logo.svg +0 -3
  220. data/app/services/post_manager/article_handler.rb +0 -10
  221. data/app/services/post_manager/blog_post_handler.rb +0 -10
  222. data/app/services/post_manager/news_handler.rb +0 -10
  223. data/app/views/admin/index/dashboard/biovision_post/_additional_items.html.erb +0 -0
  224. data/app/views/blog_posts/index.jbuilder +0 -11
  225. data/app/views/news/index.jbuilder +0 -11
  226. data/app/views/post_categories/edit.jbuilder +0 -3
  227. data/app/views/post_categories/edit.js.erb +0 -1
  228. data/app/views/post_categories/new.jbuilder +0 -3
  229. data/app/views/post_categories/new.js.erb +0 -1
  230. data/db/migrate/20170930000002_create_post_categories.rb +0 -29
  231. data/db/migrate/20170930000003_create_posts.rb +0 -60
  232. data/db/migrate/20171218111111_add_meta_fields_to_posts.rb +0 -15
  233. data/db/migrate/20171219111112_add_author_fields_to_posts.rb +0 -11
  234. data/db/migrate/20180321100000_create_post_references.rb +0 -21
  235. data/db/migrate/20180321100001_create_post_notes.rb +0 -18
  236. data/db/migrate/20180321100002_create_post_links.rb +0 -20
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fbf3b6832851e48e1450b9c63d50ac2a197b03c0b2eb05349b4f9d6f7cd58dd5
4
- data.tar.gz: f0171a57eb12a4642dffb3c115a46e5bcd63fa9287b67080427e695ce7243abb
3
+ metadata.gz: b5427643da925dc232b54e52d704e542598d5ecb780211113eaecf43484df90b
4
+ data.tar.gz: 5cfcb7077d4bd067b95b1752f4bae1c4546bd51a9903440ac77c9bdc9e708367
5
5
  SHA512:
6
- metadata.gz: 7bea4d1a8c899d26f28949e979801fcd1754819c8e371769a8e6c4024c933f2becbadddaefa695ab88fbd1ca838ce39a2a51ae689ebda12e82bb2e786e8c605c
7
- data.tar.gz: 3ae3e714da864096277d071035387e316a0ff89155d866f1491308c64dc89ecaccfce16584280db74072d0f746f2f2ec60f823335da2539cb9a3c6113b5aad79
6
+ metadata.gz: dcc7a0e1c3c4914c90e60fb97ab9064465c1ef253c97e41cd73c6dad51ececd708ea7e5ab374aa38dbdbf0f55591a3b6db15f8ce31b69d6122e41ef0c045f28e
7
+ data.tar.gz: c2db01c994e6f5f1784fc725c62da961fa3440ef49bbb0bfc771485eae652f6e427d35c27781f361cfbfe4338d9ab7aa26a6b541b593088e2b15fba461032a44
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
@@ -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,258 @@
1
+ "use strict";
2
+
3
+ const Posts = {
4
+ initialized: false,
5
+ autoInit: true,
6
+ components: {},
7
+ init: function () {
8
+ for (let component in this.components) {
9
+ if (this.components.hasOwnProperty(component)) {
10
+ if (this.components[component].hasOwnProperty("init")) {
11
+ this.components[component].init();
12
+ }
13
+ }
14
+ }
15
+
16
+ this.initialized = true;
17
+ }
18
+ };
19
+
20
+ const BiovisionPosts = {
21
+ /**
22
+ * @type {Function}
23
+ * @param e
24
+ */
25
+ loadPosts: function (e) {
26
+ e.preventDefault();
27
+
28
+ const button = this;
29
+ const container = document.getElementById(button.getAttribute('data-container'));
30
+ if (container) {
31
+ const list = container.querySelector('div.list');
32
+
33
+ if (list && !button.classList.contains('loading')) {
34
+ const url = button.getAttribute('href');
35
+ const request = Biovision.newAjaxRequest('get', url, function () {
36
+ button.classList.remove('loading');
37
+
38
+ const response = JSON.parse(this.responseText);
39
+ let nextLink;
40
+ if (response.hasOwnProperty('data')) {
41
+ response.data.forEach(function (element) {
42
+ if (element.hasOwnProperty('meta')) {
43
+ list.insertAdjacentHTML('beforeEnd', element.meta['html_preview']);
44
+ }
45
+ });
46
+ }
47
+ if (response.hasOwnProperty('links')) {
48
+ const links = response.links;
49
+ if (links.hasOwnProperty('next')) {
50
+ nextLink = links.next;
51
+ }
52
+ }
53
+ if (nextLink) {
54
+ button.setAttribute('href', nextLink);
55
+ } else {
56
+ button.classList.add('hidden');
57
+ }
58
+ });
59
+
60
+ button.classList.add('loading');
61
+ request.send();
62
+ }
63
+ }
64
+ }
65
+ };
66
+
67
+ Posts.components.calendar = {
68
+ initialized: false,
69
+ element: undefined,
70
+ dates: [],
71
+ current: 0,
72
+ buttons: {},
73
+ header: undefined,
74
+ days: undefined,
75
+ init: function () {
76
+ this.element = document.getElementById('posts-calendar');
77
+ if (this.element) {
78
+ const component = this;
79
+ const url = this.element.getAttribute('data-url');
80
+ const request = Biovision.newAjaxRequest('get', url, function () {
81
+ const response = JSON.parse(this.responseText);
82
+ if (response.hasOwnProperty('meta')) {
83
+ const meta = response['meta'];
84
+ if (meta.hasOwnProperty('dates')) {
85
+ meta.dates.forEach(function (years) {
86
+ const year = years['year'];
87
+ if (years.hasOwnProperty('months')) {
88
+ years['months'].forEach(function (months) {
89
+ if (months['days']) {
90
+ const days = {};
91
+ months["days"].forEach(function (d) {
92
+ days[d["day"]] = d["path"];
93
+ });
94
+ component.dates.push({
95
+ "year": year,
96
+ "month": months["month"],
97
+ "text": months["name"] + ' ' + year,
98
+ "days": days
99
+ })
100
+ }
101
+ });
102
+ }
103
+ });
104
+
105
+ component.select(component.dates.length - 1);
106
+ }
107
+ }
108
+ });
109
+ request.send();
110
+
111
+ this.buttons["prev"] = this.element.querySelector('button.prev');
112
+ this.buttons["next"] = this.element.querySelector('button.next');
113
+ this.buttons["prev"].addEventListener('click', this.buttonClick);
114
+ this.buttons["next"].addEventListener('click', this.buttonClick);
115
+ this.header = this.element.querySelector('.header span');
116
+ this.days = this.element.querySelector('.days');
117
+
118
+ this.initialized = true;
119
+ }
120
+ },
121
+ select: function (number) {
122
+ const component = Posts.components.calendar;
123
+ if (number < 0 || number >= component.dates.length) {
124
+ return;
125
+ }
126
+ component.current = number;
127
+ if (number > 0) {
128
+ component.buttons["prev"].setAttribute('data-number', number - 1);
129
+ component.buttons["prev"].disabled = false;
130
+ } else {
131
+ component.buttons["prev"].disabled = true;
132
+ }
133
+ if (number < component.dates.length - 1) {
134
+ component.buttons["next"].setAttribute('data-number', number + 1);
135
+ component.buttons["next"].disabled = false;
136
+ } else {
137
+ component.buttons["next"].disabled = true;
138
+ }
139
+ const item = component.dates[number];
140
+
141
+ /**
142
+ * Month number starts from 0, so we use the next month and day 0
143
+ * to get the last day of actual month
144
+ *
145
+ * @type {number}
146
+ */
147
+ const dayCount = new Date(item["year"], item["month"], 0).getDate();
148
+ const dayNumber = new Date(item["year"], item["month"] - 1, 1).getDay();
149
+ component.header.innerHTML = item["text"];
150
+ component.days.innerHTML = "";
151
+ let buffer = "";
152
+ let style = "";
153
+ for (let d = 1; d <= dayCount; d++) {
154
+ if (d === 1 && dayNumber !== 1) {
155
+ style = ' style="margin-left:calc(100% / 7 * ';
156
+ style += (dayNumber > 0) ? (dayNumber - 1) : 6;
157
+ style += ')"';
158
+ } else {
159
+ style = "";
160
+ }
161
+ buffer += '<div' + style + '><span>';
162
+ if (item.days[d]) {
163
+ buffer += '<a href="' + item.days[d] + '">' + d + '</a>';
164
+ } else {
165
+ buffer += d;
166
+ }
167
+ buffer += '</span></div>';
168
+ }
169
+ component.days.innerHTML = buffer;
170
+ },
171
+ buttonClick: function (event) {
172
+ const button = event.target;
173
+ const number = parseInt(button.getAttribute("data-number"));
174
+ Posts.components.calendar.select(number);
175
+ }
176
+ };
177
+
178
+ Posts.components.groupTagLinker = {
179
+ initialized: false,
180
+ container: undefined,
181
+ input: undefined,
182
+ list: document.createElement("ul"),
183
+ init: function () {
184
+ this.input = document.getElementById("tag-search");
185
+ if (this.input) {
186
+ this.container = this.input.parentNode.querySelector(".list-container");
187
+
188
+ if (this.container) {
189
+ const component = this;
190
+ this.list.classList.add('entity-links');
191
+ this.input.addEventListener("change", component.handler);
192
+ this.container.append(this.list);
193
+ this.initialized = true;
194
+ } else {
195
+ console.log("Cannot find container for tags list")
196
+ }
197
+ }
198
+ },
199
+ /**
200
+ * @type {Function}
201
+ */
202
+ handler: function () {
203
+ const component = Posts.components.groupTagLinker;
204
+ const query = "?q=" + encodeURIComponent(component.input.value);
205
+ const url = component.input.getAttribute('data-url') + query;
206
+
207
+ Biovision.jsonAjaxRequest("GET", url, component.parseResponse).send();
208
+ },
209
+ /**
210
+ * @type {Function}
211
+ */
212
+ parseResponse: function () {
213
+ const response = JSON.parse(this.responseText);
214
+
215
+ if (response.hasOwnProperty("data")) {
216
+ const component = Posts.components.groupTagLinker;
217
+ component.list.innerHTML = '';
218
+ response.data.forEach(component.process);
219
+ }
220
+ },
221
+ /**
222
+ *
223
+ * @type {Function}
224
+ * @param data
225
+ */
226
+ process: function (data) {
227
+ const component = Posts.components.groupTagLinker;
228
+ if (data.hasOwnProperty("meta")) {
229
+ const meta = data.meta;
230
+ const li = document.createElement('li');
231
+ const input = document.createElement('input');
232
+ const label = document.createElement('label');
233
+ const element_id = "post_tag_" + data["id"];
234
+
235
+ Biovision.components.entityLinker.apply(input);
236
+
237
+ input.setAttribute("type", "checkbox");
238
+ input.setAttribute("id", element_id);
239
+ input.setAttribute("data-url", meta["url"]);
240
+ input.checked = meta["checked"];
241
+ li.append(input);
242
+
243
+ label.setAttribute("for", element_id);
244
+ label.innerHTML = data.attributes["name"] + " (" + meta["post_type"] + ")";
245
+ li.append(label);
246
+
247
+ component.list.append(li);
248
+ }
249
+ }
250
+ };
251
+
252
+ Biovision.components.posts = Posts;
253
+
254
+ document.addEventListener('DOMContentLoaded', function () {
255
+ document.querySelectorAll('.posts-loader').forEach(function (button) {
256
+ button.addEventListener('click', BiovisionPosts.loadPosts);
257
+ });
258
+ });
@@ -0,0 +1,93 @@
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
+ }