Skip to content

Commit

Permalink
Merge pull request #8409 from tclaus/add_app_smart_banner
Browse files Browse the repository at this point in the history
Add app smart banner to web site when using an iOS device
  • Loading branch information
SuperTux88 committed Jun 4, 2023
2 parents e29f9e2 + 83a2274 commit ce32a7d
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 0 deletions.
1 change: 1 addition & 0 deletions Changelog.md
Expand Up @@ -70,6 +70,7 @@ We use yarn to install the frontend dependencies now, so you need to have that i
* Allow to select multiple aspects when posting on mobile [#8217](https://github.com/diaspora/diaspora/pull/8217)
* Add info links to drawer in mobile UI [#8405](https://github.com/diaspora/diaspora/pull/8405)
* Tell users that there is no help in mobile version, allow to switch to desktop [#8407](https://github.com/diaspora/diaspora/pull/8407)
* Add Smart App Banner on iOS devices [#8409](https://github.com/diaspora/diaspora/pull/8409)

# 0.7.18.1

Expand Down
8 changes: 8 additions & 0 deletions app/helpers/application_helper.rb
Expand Up @@ -13,6 +13,14 @@ def pod_version
AppConfig.version.number
end

def uri_with_username
if user_signed_in?
AppConfig.pod_uri + "?username=#{current_user.username}"
else
AppConfig.pod_uri
end
end

def changelog_url
return AppConfig.settings.changelog_url.get if AppConfig.settings.changelog_url.present?

Expand Down
1 change: 1 addition & 0 deletions app/views/layouts/application.html.haml
Expand Up @@ -6,6 +6,7 @@
%html{lang: I18n.locale.to_s, dir: (rtl? ? "rtl" : "ltr")}
%head{prefix: og_prefix}
%meta{name: "viewport", content: "width=device-width, initial-scale=1"}/
%meta{name: "apple-itunes-app", content: "app-id=1538074832, app-argument=#{uri_with_username}"}

- content_for :javascript do
= javascript_include_tag :main
Expand Down
30 changes: 30 additions & 0 deletions spec/helpers/application_helper_spec.rb
Expand Up @@ -165,4 +165,34 @@ def current_user
expect(pod_version).to match "0.0.1.0"
end
end

describe "#uri_with_username" do
attr_reader :current_user

before do
@current_user = alice
def user_signed_in?
true
end
end

it "displays the pod uri and username if logged in" do
allow(AppConfig).to receive(:pod_uri) { "https://diaspora.social" }
expect(uri_with_username).to match "https://diaspora.social?username=alice"
end
end

describe "#uri_with_username without logged in user" do
before do
@current_user = alice
def user_signed_in?
false
end
end

it "displays the pod uri" do
allow(AppConfig).to receive(:pod_uri) { "https://diaspora.social" }
expect(uri_with_username).to match "https://diaspora.social"
end
end
end

0 comments on commit ce32a7d

Please sign in to comment.