diff --git a/Changelog.md b/Changelog.md index 164a0cebd..1871a7165 100644 --- a/Changelog.md +++ b/Changelog.md @@ -52,6 +52,7 @@ With the port to Bootstrap 3, app/views/terms/default.haml has a new structure. * Add mobile services and privacy settings pages [#6086](https://github.com/diaspora/diaspora/pull/6086) * Optionally make your extended profile details public [#6162](https://github.com/diaspora/diaspora/pull/6162) * Add admin dashboard showing latest diaspora\* version [#6216](https://github.com/diaspora/diaspora/pull/6216) +* Display poll & location on mobile [#6238](https://github.com/diaspora/diaspora/pull/6238) # 0.5.3.0 diff --git a/app/assets/stylesheets/mobile/mobile.scss b/app/assets/stylesheets/mobile/mobile.scss index 45f3fbe6b..f2d094d62 100644 --- a/app/assets/stylesheets/mobile/mobile.scss +++ b/app/assets/stylesheets/mobile/mobile.scss @@ -10,6 +10,7 @@ @import "mobile/tags"; @import "mobile/conversations"; @import "mobile/settings"; +@import "mobile/stream_element"; a { color: #2489ce; diff --git a/app/assets/stylesheets/mobile/stream_element.scss b/app/assets/stylesheets/mobile/stream_element.scss new file mode 100644 index 000000000..13734c6a9 --- /dev/null +++ b/app/assets/stylesheets/mobile/stream_element.scss @@ -0,0 +1,16 @@ +.stream_element { + .location { + color: $text-grey; + font-size: $font-size-small; + white-space: normal; + } + + .poll { + border-top: 1px solid $border-grey; + margin-top: 20px; + padding-top: 10px; + .poll-head .question { + font-weight: bold; + } + } +} diff --git a/app/views/shared/_post_info.mobile.haml b/app/views/shared/_post_info.mobile.haml index fa262d27e..03d6aa504 100644 --- a/app/views/shared/_post_info.mobile.haml +++ b/app/views/shared/_post_info.mobile.haml @@ -30,3 +30,6 @@ = t('public') - else = t('limited') + - if !post.is_a?(Reshare) and post.location + .location + = t("posts.show.location", location: post.location.address) diff --git a/app/views/status_messages/_poll.mobile.haml b/app/views/status_messages/_poll.mobile.haml new file mode 100644 index 000000000..30dec659f --- /dev/null +++ b/app/views/status_messages/_poll.mobile.haml @@ -0,0 +1,25 @@ +.poll + .poll-head + .poll-stats.pull-right + = t("polls.votes", count: poll.participation_count) + .question + = poll.question + .poll-content + - poll.poll_answers.each do |answer| + .result-row + .result-head + - percentage = 0 + - if poll.participation_count > 0 + - percentage = (answer.vote_count / poll.participation_count * 100).round + .percentage.pull-right + = "#{percentage}%" + .answer + = answer.answer + .progress + .progress-bar{role: "progressbar", + aria: {valuenow: "#{percentage}", + valuemin: "0", + valuemax: "100"}, + style: "width: #{percentage}%;"} + %span.sr-only + = "#{percentage}%" diff --git a/app/views/status_messages/_status_message.mobile.haml b/app/views/status_messages/_status_message.mobile.haml index 5aba5358d..52f60ba74 100644 --- a/app/views/status_messages/_status_message.mobile.haml +++ b/app/views/status_messages/_status_message.mobile.haml @@ -16,8 +16,10 @@ %div{:class => direction_for(post.text)} != post.message.markdownified + - if post.poll + = render "status_messages/poll", poll: post.poll - if post.o_embed_cache != o_embed_html post.o_embed_cache - -if post.open_graph_cache + - if post.open_graph_cache .opengraph != og_html post.open_graph_cache diff --git a/config/locales/diaspora/en.yml b/config/locales/diaspora/en.yml index 969360426..20f166c0c 100644 --- a/config/locales/diaspora/en.yml +++ b/config/locales/diaspora/en.yml @@ -975,10 +975,17 @@ en: or_select_one_existing: "or select one from your already existing %{photos}" comment_email_subject: "%{name}’s photo" + polls: + votes: + zero: "%{count} votes so far" + one: "%{count} vote so far" + other: "%{count} votes so far" + posts: presenter: title: "A post from %{name}" show: + location: "Posted from: %{location}" destroy: "Delete" permalink: "Permalink" not_found: "Sorry, we couldn’t find that post." diff --git a/spec/factories.rb b/spec/factories.rb index 42c39caca..a9989e077 100644 --- a/spec/factories.rb +++ b/spec/factories.rb @@ -99,6 +99,12 @@ FactoryGirl.define do end end + factory(:status_message_with_location) do + after(:build) do |sm| + FactoryGirl.create(:location, status_message: sm) + end + end + factory(:status_message_with_photo) do sequence(:text) {|n| "There are #{n} ninjas in this photo." } after(:build) do |sm| @@ -134,6 +140,7 @@ FactoryGirl.define do end factory(:location) do + address "unicorn city" lat 1 lng 2 end diff --git a/spec/integration/mobile_posts_spec.rb b/spec/integration/mobile_posts_spec.rb new file mode 100644 index 000000000..058b06948 --- /dev/null +++ b/spec/integration/mobile_posts_spec.rb @@ -0,0 +1,27 @@ +require "spec_helper" + +describe PostsController, type: :request do + context "with a poll" do + let(:sm) { FactoryGirl.build(:status_message_with_poll, public: true) } + + it "displays the poll" do + get "/posts/#{sm.id}", format: :mobile + + expect(response.status).to eq(200) + expect(response.body).to match(/div class='poll'/) + expect(response.body).to match(/#{sm.poll.poll_answers.first.answer}/) + end + end + + context "with a location" do + let(:sm) { FactoryGirl.build(:status_message_with_location, public: true) } + + it "displays the location" do + get "/posts/#{sm.id}", format: :mobile + + expect(response.status).to eq(200) + expect(response.body).to match(/div class='location'/) + expect(response.body).to match(/#{I18n.t("posts.show.location", location: sm.location.address)}/) + end + end +end