polivalente 0.6.2 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (79) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +4 -0
  3. data/app/assets/build/css/components/_bookmarks.scss +20 -0
  4. data/app/assets/build/css/components/_colors.scss +104 -0
  5. data/app/assets/build/css/components/_forms.scss +23 -0
  6. data/app/assets/build/css/components/_pagination.scss +75 -0
  7. data/app/assets/build/css/components/_player.scss +148 -0
  8. data/app/assets/build/css/components/_tags.scss +29 -0
  9. data/app/assets/build/css/components/_themes.scss +69 -0
  10. data/app/assets/build/css/components/_tribute.scss +25 -0
  11. data/app/assets/build/css/components/plyr.css +1 -0
  12. data/app/assets/build/css/components/trix/_clipboard.scss +27 -0
  13. data/app/assets/build/css/components/trix/_trix.scss +181 -0
  14. data/app/assets/build/css/index.css +19 -0
  15. data/app/assets/build/js/application.js +2 -0
  16. data/app/assets/build/js/controllers/accordion_controller.js +21 -0
  17. data/app/assets/build/js/controllers/dynamic_select_controller.js +22 -0
  18. data/app/assets/build/js/controllers/index.js +33 -0
  19. data/app/assets/build/js/controllers/offline_controller.js +19 -0
  20. data/app/assets/build/js/controllers/reactive_text_controller.js +15 -0
  21. data/app/assets/build/js/controllers/text_counter_controller.js +38 -0
  22. data/app/assets/build/js/controllers/theme_controller.js +36 -0
  23. data/app/assets/build/js/controllers/trix_attachment_blocker_controller.js +15 -0
  24. data/app/assets/build/js/controllers/trix_autocomplete_controller.js +86 -0
  25. data/app/assets/build/js/controllers/trix_blockcode_controller.js +41 -0
  26. data/app/assets/build/js/controllers/trix_clipboard_controller.js +50 -0
  27. data/app/assets/build/js/controllers/trix_color_controller.js +49 -0
  28. data/app/assets/build/js/controllers/trix_highlight_controller.js +55 -0
  29. data/app/assets/build/js/controllers/trix_plyr_controller.js +86 -0
  30. data/app/assets/build/js/controllers/trix_toolbar_controller.js +48 -0
  31. data/app/assets/config/polivalente_manifest.js +1 -0
  32. data/app/assets/javascripts/polivalente/application.js +173 -0
  33. data/app/assets/stylesheets/polivalente/application.css +3 -14
  34. data/app/assets/stylesheets/polivalente/styles.css +1928 -0
  35. data/app/controllers/polivalente/application_controller.rb +2 -0
  36. data/app/controllers/polivalente/archives_controller.rb +18 -0
  37. data/app/controllers/polivalente/autocomplete_controller.rb +2 -3
  38. data/app/controllers/polivalente/comments_controller.rb +27 -0
  39. data/app/controllers/polivalente/trashes_controller.rb +18 -0
  40. data/app/controllers/polivalente/users_controller.rb +42 -0
  41. data/app/helpers/polivalente/gravatar_helper.rb +0 -4
  42. data/app/models/polivalente/tag.rb +1 -0
  43. data/app/views/layouts/polivalente/application.html.erb +9 -3
  44. data/app/views/polivalente/archives/_archive.html.erb +2 -0
  45. data/app/views/polivalente/archives/index.html.erb +3 -0
  46. data/app/views/polivalente/archives/show.html.erb +3 -0
  47. data/app/views/polivalente/autocomplete/tags.json.jbuilder +1 -0
  48. data/app/views/polivalente/autocomplete/users.json.jbuilder +1 -0
  49. data/app/views/polivalente/shared/_notices.html.erb +10 -0
  50. data/app/views/polivalente/shared/_offline_indicator.html.erb +10 -0
  51. data/app/views/polivalente/shared/_theme_toggle.html.erb +1 -0
  52. data/app/views/polivalente/tags/_cloud.html.erb +7 -0
  53. data/app/views/polivalente/tags/_list.html.erb +5 -0
  54. data/app/views/polivalente/tags/_tag.html.erb +1 -0
  55. data/app/views/polivalente/tags/_tag.json.jbuilder +4 -0
  56. data/app/views/polivalente/trashes/_trash.html.erb +2 -0
  57. data/app/views/polivalente/trashes/index.html.erb +3 -0
  58. data/app/views/polivalente/trashes/show.html.erb +3 -0
  59. data/app/views/polivalente/users/_form.html.erb +38 -0
  60. data/app/views/polivalente/users/_user.html.erb +4 -0
  61. data/app/views/polivalente/users/_user.json.jbuilder +4 -0
  62. data/app/views/polivalente/users/activities/_activity.html.erb +12 -0
  63. data/app/views/polivalente/users/activities/_recent.html.erb +17 -0
  64. data/app/views/polivalente/users/edit.html.erb +13 -0
  65. data/app/views/polivalente/users/related/_user.html.erb +14 -0
  66. data/app/views/polivalente/users/related/_users.html.erb +14 -0
  67. data/app/views/polivalente/users/show.html.erb +180 -0
  68. data/config/locales/en.yml +72 -0
  69. data/config/locales/es.yml +72 -0
  70. data/config/locales/fr.yml +74 -0
  71. data/config/locales/pt.yml +72 -0
  72. data/config/routes.rb +6 -0
  73. data/lib/generators/polivalente/install/install_generator.rb +1 -1
  74. data/lib/generators/polivalente/locales/locales_generator.rb +11 -0
  75. data/lib/generators/polivalente/templates/user.rb +3 -0
  76. data/lib/polivalente/engine.rb +1 -0
  77. data/lib/polivalente/version.rb +1 -1
  78. data/lib/polivalente.rb +3 -0
  79. metadata +107 -2
@@ -0,0 +1,55 @@
1
+ import {Controller} from "@hotwired/stimulus"
2
+ import highlightJs from 'highlight.js'
3
+
4
+
5
+ // Connects to data-controller="trix-highlight"
6
+ export default class extends Controller {
7
+ connect() {
8
+ console.log("trix-highlight")
9
+
10
+ highlightJs.configure({
11
+ languages: [
12
+ 'applescript',
13
+ 'bash',
14
+ 'css',
15
+ 'erb',
16
+ 'html',
17
+ 'javascript',
18
+ 'php',
19
+ 'python',
20
+ 'ruby',
21
+ 'swift',
22
+ 'typescript',
23
+ ]
24
+ })
25
+
26
+ highlightJs.highlightAll()
27
+
28
+ const formatBlocks = () => {
29
+ document.querySelectorAll('pre')
30
+ .forEach((block) => highlightJs.highlightElement(block))
31
+ }
32
+
33
+ const createClipboardCopyButton = () => {
34
+ document.querySelectorAll('article')
35
+ .forEach((article) => {
36
+ article.querySelectorAll('pre')
37
+ .forEach((block) => {
38
+ if (block.previousSibling.tagName === 'BUTTON') return;
39
+
40
+ const sample = document.createElement('div')
41
+ sample.classList.add('code-sample', 'my-3')
42
+ sample.insertAdjacentHTML('afterbegin', '<button class="copy z-4"></button>')
43
+
44
+ block.replaceWith(sample)
45
+
46
+ sample.insertAdjacentElement('beforeend', block)
47
+ })
48
+ })
49
+ }
50
+
51
+ //
52
+ formatBlocks()
53
+ createClipboardCopyButton()
54
+ }
55
+ }
@@ -0,0 +1,86 @@
1
+ import {Controller} from "@hotwired/stimulus"
2
+ import Plyr from "plyr"
3
+ import Trix from "trix"
4
+
5
+ // Connects to data-controller="trix-plyr"
6
+ export default class extends Controller {
7
+ static targets = ['editor']
8
+
9
+ get validContent() {
10
+ return ['audio', 'video']
11
+ }
12
+
13
+ get options() {
14
+ return {
15
+ autopause: true,
16
+ controls: [
17
+ 'play-large',
18
+ 'play',
19
+ 'progress',
20
+ 'current-time',
21
+ 'mute',
22
+ 'volume',
23
+ 'captions',
24
+ 'settings',
25
+ 'pip',
26
+ 'airplay',
27
+ 'fullscreen'
28
+ ],
29
+ settings: ['captions', 'quality', 'speed', 'loop'],
30
+ captions: {active: true, language: 'auto'},
31
+ fullscreen: {enabled: true, fallback: true, iosNative: false, container: null},
32
+ }
33
+ }
34
+
35
+ get container() {
36
+ return this['hasEditorTarget']
37
+ ? this['editorTarget']
38
+ : document.querySelector('.trix-content')
39
+ }
40
+
41
+ connect() {
42
+ let isEditor = !!(this.container.attributes.contentEditable)
43
+
44
+ // if (isEditor)
45
+ // this.parsePlayerInEditor()
46
+ // else
47
+ // this.createPlayers()
48
+ }
49
+
50
+ createPlayers() {
51
+ window.players = Array
52
+ .from(document.querySelectorAll('audio, video'))
53
+ .map(player => new Plyr(player, this.options))
54
+ }
55
+
56
+ parsePlayerInEditor() {
57
+ window.attachments = []
58
+ window.originalAttachments = []
59
+
60
+ this.container.editor
61
+ .getDocument()
62
+ .getAttachments()
63
+ .filter(attachment => this.validContent.includes(attachment.getContentType().split('/')[0]))
64
+ .forEach(attachment => {
65
+ let range = this.container.editor.getDocument().getRangeOfAttachment(attachment)
66
+ let src = attachment.getAttributes().url
67
+ let tag = attachment.getContentType().split('/')[0]
68
+
69
+ let content = `<${tag} src="${src}" controls="true"></${tag}>`
70
+
71
+ // Add Plyr attachment for preview purposes only
72
+ this.container.editor.setSelectedRange([range[0] + 1, range[1] + 1])
73
+
74
+ let newAttachment = new Trix.Attachment({
75
+ content,
76
+ contentType: 'plyr',
77
+ serialize: false,
78
+ trixSerialize: false
79
+ })
80
+ this.container.editor.insertAttachment(newAttachment)
81
+
82
+ // window.attachments.push(newAttachment)
83
+ // window.originalAttachments.push(attachment)
84
+ })
85
+ }
86
+ }
@@ -0,0 +1,48 @@
1
+ import {Controller} from "@hotwired/stimulus"
2
+ import Trix from "trix"
3
+
4
+ const {lang} = Trix.config;
5
+
6
+ // Connects to data-controller="trix-toolbar"
7
+ export default class extends Controller {
8
+ connect() {
9
+ console.log("trix-toolbar")
10
+
11
+ // /* What the newly created button does */
12
+ // Trix.config.textAttributes.red = {
13
+ // style: { color: "red" },
14
+ // parser: (element) => element.style.color === "red",
15
+ // inheritable: true
16
+ // }
17
+
18
+ // /* Insert the button visual in the default toolbar */
19
+ // addEventListener("trix-initialize", function(event) {
20
+ // var buttonHTML = '<button type="button" class="trix-button" data-trix-attribute="red">RED</button>'
21
+
22
+ // event.target.toolbarElement.
23
+ // querySelector(".trix-button-group").
24
+ // insertAdjacentHTML("beforeend", buttonHTML)
25
+ // })
26
+
27
+ // ===============
28
+
29
+ // Grab a reference to the toolbar(s) on the page.
30
+ const toolbar = this.element.previousSibling
31
+
32
+ // HTML for our buttons
33
+ const h2ButtonHTML = '<button type="button" class="trix-button" data-trix-attribute="heading" title="Subheading">H2</button>'
34
+ const h3ButtonHTML = '<button type="button" class="trix-button" data-trix-attribute="subHeading" title="Subheading">H3</button>'
35
+
36
+ // Only apply event listeners once to the toolbars
37
+ addEventListener("trix-initialize", (event) => {
38
+ const sibling1 = toolbar.querySelector(".trix-button--icon-increase-nesting-level")
39
+ sibling1.insertAdjacentHTML("afterend", h2ButtonHTML)
40
+ const sibling2 = toolbar.querySelector("[data-trix-attribute='heading']")
41
+ sibling2.insertAdjacentHTML("afterend", h3ButtonHTML)
42
+ }/*, {once: true}*/)
43
+
44
+ console.log("trix-toolbar-post")
45
+ }
46
+
47
+ disconnect () {}
48
+ }
@@ -1 +1,2 @@
1
1
  //= link_directory ../stylesheets/polivalente .css
2
+ //= link_directory ../javascripts .js