about summary refs log tree commit diff
path: root/app/views/stream_entries
diff options
context:
space:
mode:
authorThibaut Girka <thib@sitedethib.com>2019-03-05 19:23:16 +0100
committerThibaut Girka <thib@sitedethib.com>2019-03-05 19:23:16 +0100
commitf513317ba262d9f5d7aa7dd66f8b61690297e107 (patch)
tree6732fcf1178fc3e27404c6830bc2bc1c832659ae /app/views/stream_entries
parent2a4ce7458a16c64029842fde210089453be2ede1 (diff)
parent7d5e2dda78414316f9cf09fcf6096d6a158da312 (diff)
Merge branch 'master' into glitch-soc/merge-upstream
Conflicts:
- app/models/status.rb
- db/schema.rb

Both conflicts are caused by us having extra database columns.
Diffstat (limited to 'app/views/stream_entries')
-rw-r--r--app/views/stream_entries/_detailed_status.html.haml5
-rw-r--r--app/views/stream_entries/_poll.html.haml29
-rw-r--r--app/views/stream_entries/_simple_status.html.haml5
3 files changed, 37 insertions, 2 deletions
diff --git a/app/views/stream_entries/_detailed_status.html.haml b/app/views/stream_entries/_detailed_status.html.haml
index e123d657f..b19d2452a 100644
--- a/app/views/stream_entries/_detailed_status.html.haml
+++ b/app/views/stream_entries/_detailed_status.html.haml
@@ -22,7 +22,10 @@
         %a.status__content__spoiler-link{ href: '#' }= t('statuses.show_more')
     .e-content{ lang: status.language, style: "display: #{!current_account&.user&.setting_expand_spoilers && status.spoiler_text? ? 'none' : 'block'}; direction: #{rtl_status?(status) ? 'rtl' : 'ltr'}" }= Formatter.instance.format(status, custom_emojify: true, autoplay: autoplay)
 
-  - if !status.media_attachments.empty?
+  - if status.poll
+    = react_component :poll, disabled: true, poll: ActiveModelSerializers::SerializableResource.new(status.poll, serializer: REST::PollSerializer, scope: current_user, scope_name: :current_user).as_json do
+      = render partial: 'stream_entries/poll', locals: { poll: status.poll }
+  - elsif !status.media_attachments.empty?
     - if status.media_attachments.first.video?
       - video = status.media_attachments.first
       = react_component :video, src: video.file.url(:original), preview: video.file.url(:small), sensitive: !current_account&.user&.show_all_media? && status.sensitive? || current_account&.user&.hide_all_media?, width: 670, height: 380, detailed: true, inline: true, alt: video.description do
diff --git a/app/views/stream_entries/_poll.html.haml b/app/views/stream_entries/_poll.html.haml
new file mode 100644
index 000000000..c7e5e0c63
--- /dev/null
+++ b/app/views/stream_entries/_poll.html.haml
@@ -0,0 +1,29 @@
+- options      = (!poll.expired? && poll.hide_totals?) ? poll.unloaded_options : poll.loaded_options
+- voted        = user_signed_in? && poll.votes.where(account: current_account).exists?
+- show_results = voted || poll.expired?
+
+.poll
+  %ul
+    - options.each do |option|
+      %li
+        - if show_results
+          - percent = 100 * option.votes_count / poll.votes_count
+          %span.poll__chart{ style: "width: #{percent}%" }
+
+          %label.poll__text><
+            %span.poll__number= percent.round
+            = option.title
+        - else
+          %label.poll__text><
+            %span.poll__input{ class: poll.multiple? ? 'checkbox' : nil}><
+            = option.title
+  .poll__footer
+    - unless show_results
+      %button.button.button-secondary{ disabled: true }
+        = t('statuses.poll.vote')
+
+    %span= t('statuses.poll.total_votes', count: poll.votes_count)
+
+    - unless poll.expires_at.nil?
+      ·
+      %span= l poll.expires_at
diff --git a/app/views/stream_entries/_simple_status.html.haml b/app/views/stream_entries/_simple_status.html.haml
index 28b4e3217..d3441ca90 100644
--- a/app/views/stream_entries/_simple_status.html.haml
+++ b/app/views/stream_entries/_simple_status.html.haml
@@ -27,7 +27,10 @@
     .e-content{ lang: status.language, style: "display: #{!current_account&.user&.setting_expand_spoilers && status.spoiler_text? ? 'none' : 'block'}; direction: #{rtl_status?(status) ? 'rtl' : 'ltr'}" }<
       = Formatter.instance.format(status, custom_emojify: true, autoplay: autoplay)
 
-  - if !status.media_attachments.empty?
+  - if status.poll
+    = react_component :poll, disabled: true, poll: ActiveModelSerializers::SerializableResource.new(status.poll, serializer: REST::PollSerializer, scope: current_user, scope_name: :current_user).as_json do
+      = render partial: 'stream_entries/poll', locals: { poll: status.poll }
+  - elsif !status.media_attachments.empty?
     - if status.media_attachments.first.video?
       - video = status.media_attachments.first
       = react_component :video, src: video.file.url(:original), preview: video.file.url(:small), sensitive: !current_account&.user&.show_all_media? && status.sensitive? || current_account&.user&.hide_all_media?, width: 610, height: 343, inline: true, alt: video.description do