Use `/@username` for profile paths
This commit is contained in:
parent
fe8be8c3cb
commit
fc161e2dcf
|
@ -143,19 +143,20 @@ Rails.application.routes.draw do
|
||||||
match '/inbox/:author', to: 'inbox#show', via: 'get'
|
match '/inbox/:author', to: 'inbox#show', via: 'get'
|
||||||
|
|
||||||
match '/user/:username(/p/:page)', to: 'user#show', via: 'get', defaults: {page: 1}
|
match '/user/:username(/p/:page)', to: 'user#show', via: 'get', defaults: {page: 1}
|
||||||
match '/@:username(/p/:page)', to: 'user#show', via: 'get', as: :show_user_profile_alt, defaults: {page: 1}
|
match '/@:username(/p/:page)', to: 'user#show', via: 'get', as: :show_user_profile, defaults: {page: 1}
|
||||||
match '/@:username/a/:id', to: 'answer#show', via: 'get', as: :show_user_answer_alt
|
match '/@:username/a/:id', to: 'answer#show', via: 'get', as: :show_user_answer
|
||||||
match '/@:username/q/:id', to: 'question#show', via: 'get', as: :show_user_question_alt
|
match '/@:username/q/:id', to: 'question#show', via: 'get', as: :show_user_question
|
||||||
match '/@:username/followers(/p/:page)', to: 'user#followers', via: 'get', as: :show_user_followers_alt, defaults: {page: 1}
|
match '/@:username/followers(/p/:page)', to: 'user#followers', via: 'get', as: :show_user_followers, defaults: {page: 1}
|
||||||
match '/@:username/followings(/p/:page)', to: 'user#followings', via: 'get', as: :show_user_followings_alt, defaults: {page: 1}
|
match '/@:username/followings(/p/:page)', to: 'user#followings', via: 'get', as: :show_user_followings, defaults: {page: 1}
|
||||||
match '/@:username/friends(/p/:page)', to: redirect('/@%{username}/followings/p/%{page}'), via: 'get', defaults: {page: 1}
|
match '/@:username/friends(/p/:page)', to: redirect('/@%{username}/followings/p/%{page}'), via: 'get', defaults: {page: 1}
|
||||||
match '/:username(/p/:page)', to: 'user#show', via: 'get', as: :show_user_profile, defaults: {page: 1}
|
match '/@:username/questions(/p/:page)', to: 'user#questions', via: 'get', as: :show_user_questions, defaults: {page: 1}
|
||||||
match '/:username/a/:id', to: 'answer#show', via: 'get', as: :show_user_answer
|
match '/:username(/p/:page)', to: 'user#show', via: 'get', as: :show_user_profile_alt, defaults: {page: 1}
|
||||||
match '/:username/q/:id', to: 'question#show', via: 'get', as: :show_user_question
|
match '/:username/a/:id', to: 'answer#show', via: 'get', as: :show_user_answer_alt
|
||||||
match '/:username/followers(/p/:page)', to: 'user#followers', via: 'get', as: :show_user_followers, defaults: {page: 1}
|
match '/:username/q/:id', to: 'question#show', via: 'get', as: :show_user_question_alt
|
||||||
match '/:username/followings(/p/:page)', to: 'user#followings', via: 'get', as: :show_user_followings, defaults: {page: 1}
|
match '/:username/followers(/p/:page)', to: 'user#followers', via: 'get', as: :show_user_followers_alt, defaults: {page: 1}
|
||||||
|
match '/:username/followings(/p/:page)', to: 'user#followings', via: 'get', as: :show_user_followings_alt, defaults: {page: 1}
|
||||||
match '/:username/friends(/p/:page)', to: redirect('/%{username}/followings/p/%{page}'), via: 'get', defaults: {page: 1}
|
match '/:username/friends(/p/:page)', to: redirect('/%{username}/followings/p/%{page}'), via: 'get', defaults: {page: 1}
|
||||||
match '/:username/questions(/p/:page)', to: 'user#questions', via: 'get', as: :show_user_questions, defaults: {page: 1}
|
match '/:username/questions(/p/:page)', to: 'user#questions', via: 'get', as: :show_user_questions_alt, defaults: {page: 1}
|
||||||
|
|
||||||
match '/feedback/consent', to: 'feedback#consent', via: 'get', as: 'feedback_consent'
|
match '/feedback/consent', to: 'feedback#consent', via: 'get', as: 'feedback_consent'
|
||||||
match '/feedback/consent/update', to: 'feedback#update', via: 'post', as: 'feedback_consent_update'
|
match '/feedback/consent/update', to: 'feedback#update', via: 'post', as: 'feedback_consent_update'
|
||||||
|
|
|
@ -18,7 +18,7 @@ describe ApplicationHelper::GraphMethods, :type => :helper do
|
||||||
<meta property="og:title" content="Cunes">
|
<meta property="og:title" content="Cunes">
|
||||||
<meta property="og:type" content="profile">
|
<meta property="og:type" content="profile">
|
||||||
<meta property="og:image" content="http://test.host/images/large/no_avatar.png">
|
<meta property="og:image" content="http://test.host/images/large/no_avatar.png">
|
||||||
<meta property="og:url" content="http://test.host/raccoons">
|
<meta property="og:url" content="http://test.host/@raccoons">
|
||||||
<meta property="og:description" content="A bunch of raccoons in a trenchcoat.">
|
<meta property="og:description" content="A bunch of raccoons in a trenchcoat.">
|
||||||
<meta property="og:site_name" content="pineapplespring">
|
<meta property="og:site_name" content="pineapplespring">
|
||||||
<meta property="profile:username" content="raccoons">
|
<meta property="profile:username" content="raccoons">
|
||||||
|
@ -66,7 +66,7 @@ describe ApplicationHelper::GraphMethods, :type => :helper do
|
||||||
<meta property="og:title" content="raccoons answered: #{answer.question.content}">
|
<meta property="og:title" content="raccoons answered: #{answer.question.content}">
|
||||||
<meta property="og:type" content="article">
|
<meta property="og:type" content="article">
|
||||||
<meta property="og:image" content="http://test.host/images/large/no_avatar.png">
|
<meta property="og:image" content="http://test.host/images/large/no_avatar.png">
|
||||||
<meta property="og:url" content="http://test.host/raccoons/a/#{answer.id}">
|
<meta property="og:url" content="http://test.host/@raccoons/a/#{answer.id}">
|
||||||
<meta property="og:description" content="#{answer.content}">
|
<meta property="og:description" content="#{answer.content}">
|
||||||
<meta property="og:site_name" content="pineapplespring">
|
<meta property="og:site_name" content="pineapplespring">
|
||||||
EOS
|
EOS
|
||||||
|
|
|
@ -20,7 +20,7 @@ describe MarkdownHelper, type: :helper do
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should transform mentions into links" do
|
it "should transform mentions into links" do
|
||||||
expect(markdown("@jake_weary")).to eq('<p><a href="/jake_weary">@jake_weary</a></p>')
|
expect(markdown("@jake_weary")).to eq('<p><a href="/@jake_weary">@jake_weary</a></p>')
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should escape text in links" do
|
it "should escape text in links" do
|
||||||
|
|
|
@ -46,7 +46,7 @@ describe SocialHelper::TumblrMethods, :type => :helper do
|
||||||
subject { tumblr_body(answer) }
|
subject { tumblr_body(answer) }
|
||||||
|
|
||||||
it 'should return a proper body' do
|
it 'should return a proper body' do
|
||||||
expect(subject).to eq("aaaa\n\n[Smile or comment on the answer here](https://example.com/#{answer.user.screen_name}/a/#{answer.id})")
|
expect(subject).to eq("aaaa\n\n[Smile or comment on the answer here](https://example.com/@#{answer.user.screen_name}/a/#{answer.id})")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -54,7 +54,7 @@ describe SocialHelper::TumblrMethods, :type => :helper do
|
||||||
subject { tumblr_share_url(answer) }
|
subject { tumblr_share_url(answer) }
|
||||||
|
|
||||||
it 'should return a proper share link' do
|
it 'should return a proper share link' do
|
||||||
expect(subject).to eq("https://www.tumblr.com/widgets/share/tool?shareSource=legacy&posttype=text&title=#{CGI.escape(tumblr_title(answer))}&url=#{CGI.escape("https://example.com/#{answer.user.screen_name}/a/#{answer.id}")}&caption=&content=#{CGI.escape(tumblr_body(answer))}")
|
expect(subject).to eq("https://www.tumblr.com/widgets/share/tool?shareSource=legacy&posttype=text&title=#{CGI.escape(tumblr_title(answer))}&url=#{CGI.escape("https://example.com/@#{answer.user.screen_name}/a/#{answer.id}")}&caption=&content=#{CGI.escape(tumblr_body(answer))}")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -23,7 +23,7 @@ describe SocialHelper::TwitterMethods, :type => :helper do
|
||||||
subject { prepare_tweet(answer) }
|
subject { prepare_tweet(answer) }
|
||||||
|
|
||||||
it 'should return a properly formatted tweet' do
|
it 'should return a properly formatted tweet' do
|
||||||
expect(subject).to eq("#{'q' * 123}… — #{'a' * 124}… https://example.com/#{user.screen_name}/a/#{answer.id}")
|
expect(subject).to eq("#{'q' * 123}… — #{'a' * 124}… https://example.com/@#{user.screen_name}/a/#{answer.id}")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -34,7 +34,7 @@ describe SocialHelper::TwitterMethods, :type => :helper do
|
||||||
subject { prepare_tweet(answer, '#askracc') }
|
subject { prepare_tweet(answer, '#askracc') }
|
||||||
|
|
||||||
it 'should include the suffix after the link' do
|
it 'should include the suffix after the link' do
|
||||||
expect(subject).to eq("question — answer #askracc https://example.com/#{user.screen_name}/a/#{answer.id}")
|
expect(subject).to eq("question — answer #askracc https://example.com/@#{user.screen_name}/a/#{answer.id}")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -42,7 +42,7 @@ describe SocialHelper::TwitterMethods, :type => :helper do
|
||||||
subject { prepare_tweet(answer, '#askracc') }
|
subject { prepare_tweet(answer, '#askracc') }
|
||||||
|
|
||||||
it 'should shorten the tweet while keeping the suffix intact' do
|
it 'should shorten the tweet while keeping the suffix intact' do
|
||||||
expect(subject).to eq("#{'q' * 120}… — #{'a' * 120}… #askracc https://example.com/#{user.screen_name}/a/#{answer.id}")
|
expect(subject).to eq("#{'q' * 120}… — #{'a' * 120}… #askracc https://example.com/@#{user.screen_name}/a/#{answer.id}")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -57,7 +57,7 @@ describe SocialHelper::TwitterMethods, :type => :helper do
|
||||||
subject { prepare_tweet(answer) }
|
subject { prepare_tweet(answer) }
|
||||||
|
|
||||||
it 'should return a properly formatted tweet' do
|
it 'should return a properly formatted tweet' do
|
||||||
expect(subject).to eq("#{answer.question.content} — #{answer.content} https://example.com/#{user.screen_name}/a/#{answer.id}")
|
expect(subject).to eq("#{answer.question.content} — #{answer.content} https://example.com/@#{user.screen_name}/a/#{answer.id}")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -29,7 +29,7 @@ describe Services::Twitter do
|
||||||
it "posts a shortened tweet" do
|
it "posts a shortened tweet" do
|
||||||
service.post(answer)
|
service.post(answer)
|
||||||
|
|
||||||
expect(twitter_client).to have_received(:update!).with("#{'q' * 123}… — #{'a' * 124}… https://example.com/#{user.screen_name}/a/#{answer.id}")
|
expect(twitter_client).to have_received(:update!).with("#{'q' * 123}… — #{'a' * 124}… https://example.com/@#{user.screen_name}/a/#{answer.id}")
|
||||||
end
|
end
|
||||||
|
|
||||||
it "posts an un-shortened tweet" do
|
it "posts an un-shortened tweet" do
|
||||||
|
@ -40,7 +40,7 @@ describe Services::Twitter do
|
||||||
|
|
||||||
service.post(answer)
|
service.post(answer)
|
||||||
|
|
||||||
expect(twitter_client).to have_received(:update!).with("#{answer.question.content} — #{answer.content} https://example.com/#{user.screen_name}/a/#{answer.id}")
|
expect(twitter_client).to have_received(:update!).with("#{answer.question.content} — #{answer.content} https://example.com/@#{user.screen_name}/a/#{answer.id}")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
Loading…
Reference in New Issue