Skip to content

Commit f789492

Browse files
committed
fix: http status correctness improvements
1 parent 89b5b61 commit f789492

File tree

10 files changed

+14
-120
lines changed

10 files changed

+14
-120
lines changed

.env.sample

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,6 @@ CERTIFICATES_FOLDER_PATH=
3030
HCAPTCHA_SECRET_KEY=
3131
HCAPTCHA_SITE_KEY=
3232

33-
# NewRelic (Optional)
34-
NEW_RELIC_ENABLED=false
35-
NEW_RELIC_THREAD_PROFILER_ENABLED=false
36-
NEW_RELIC_LICENSE_KEY=
37-
NEW_RELIC_APP_NAME=Listed
38-
3933
# Domain Events
4034
#SNS_TOPIC_ARN=
4135
#SQS_QUEUE_URL=

Gemfile

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,6 @@ gem "lograge", "~> 0.11.2"
5858

5959
gem "aws-sdk-route53", "~> 1.40"
6060

61-
gem "newrelic_rpm", "= 8.2.0"
62-
63-
gem "newrelic-infinite_tracing", "= 8.2.0"
64-
6561
gem "shoryuken", "~> 5.3"
6662

6763
gem "capistrano-shoryuken", "~> 0.1.5"

Gemfile.lock

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -133,20 +133,6 @@ GEM
133133
ffi (1.15.4)
134134
globalid (1.0.0)
135135
activesupport (>= 5.0)
136-
google-protobuf (3.19.1)
137-
google-protobuf (3.19.1-x86_64-darwin)
138-
google-protobuf (3.19.1-x86_64-linux)
139-
googleapis-common-protos-types (1.3.0)
140-
google-protobuf (~> 3.14)
141-
grpc (1.42.0)
142-
google-protobuf (~> 3.18)
143-
googleapis-common-protos-types (~> 1.0)
144-
grpc (1.42.0-x86_64-darwin)
145-
google-protobuf (~> 3.18)
146-
googleapis-common-protos-types (~> 1.0)
147-
grpc (1.42.0-x86_64-linux)
148-
google-protobuf (~> 3.18)
149-
googleapis-common-protos-types (~> 1.0)
150136
haml (5.2.2)
151137
temple (>= 0.8.0)
152138
tilt
@@ -191,10 +177,6 @@ GEM
191177
net-scp (3.0.0)
192178
net-ssh (>= 2.6.5, < 7.0.0)
193179
net-ssh (6.1.0)
194-
newrelic-infinite_tracing (8.2.0)
195-
grpc (~> 1.34)
196-
newrelic_rpm (= 8.2.0)
197-
newrelic_rpm (8.2.0)
198180
nio4r (2.5.8)
199181
nokogiri (1.12.5-arm64-darwin)
200182
racc (~> 1.4)
@@ -349,8 +331,6 @@ DEPENDENCIES
349331
lograge (~> 0.11.2)
350332
mini_racer
351333
mysql2
352-
newrelic-infinite_tracing (= 8.2.0)
353-
newrelic_rpm (= 8.2.0)
354334
puma (~> 4.3)
355335
rack-cors
356336
rails (= 5.2.5)

app/controllers/application_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ def redirect_to_authenticated_settings(author)
5050
end
5151

5252
def not_found
53-
redirect_to "#{ENV['HOST']}/"
53+
render :file => "#{Rails.root}/public/404.html", :status => 404
5454
end
5555

5656
end

app/controllers/authors_controller.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ class AuthorsController < ApplicationController
1818

1919
@pages = @display_author.pages if @display_author
2020
@styles = @display_author.css if @display_author && @display_author.custom_theme_enabled
21+
@canonical = @display_author.url if @display_author
2122

2223
set_meta_images_for_author(@display_author)
2324
}

app/controllers/posts_controller.rb

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ def metatype_to_contenttype(metatype)
1919
}[metatype]
2020
end
2121

22-
before_action :find_post, except: [:unpublish, :change_privacy, :delete]
22+
before_action :find_post, only: [:show]
2323

2424
def find_page(author, title)
2525
return unless author
@@ -50,7 +50,6 @@ def find_post
5050
@post = find_page(author, params[:id])
5151
end
5252
if @post && @post.unlisted == true
53-
not_found
5453
return
5554
end
5655
elsif params[:custom_path]
@@ -64,21 +63,13 @@ def find_post
6463

6564
domain = Domain.find_by(domain: request.host)
6665
if domain && @post && @post.author != domain.author
67-
not_found
6866
return
6967
end
7068
end
7169

7270
def show
7371
if !@post || !@post.published
74-
author = Author.find_author_from_path(request.path)
75-
# Go to author page
76-
if author
77-
redirect_to author.url
78-
else
79-
not_found
80-
end
81-
return
72+
return not_found
8273
end
8374

8475
@next = @post.next

app/views/layouts/application.html.erb

Lines changed: 8 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@
88
<% @canonical = @post.canonical %>
99
<% @meta_image = @post.image_url if @post.image_url %>
1010
<% @twitter_style = "summary_large_image" if @post.image_url %>
11+
12+
<% if @post.unlisted %>
13+
<meta name="robots" content="noindex">
14+
<% end %>
15+
1116
<% elsif !@title && !@desc %>
1217
<% @title = "Listed" %>
1318
<% @desc = "Listed allows you to create an online publication with automatic email newsletters delivered to your readers, directly from Standard Notes. It's ideal for creating a public journal, or sharing domain-specific knowledge."%>
@@ -68,33 +73,9 @@
6873
</style>
6974
<% end %>
7075

71-
<!-- Piwik -->
72-
<script type="text/javascript">
73-
var _paq = _paq || [];
74-
/* tracker methods like "setCustomDimension" should be called before "trackPageView" */
75-
_paq.push(['trackPageView']);
76-
_paq.push(['enableLinkTracking']);
77-
(function() {
78-
var u="//matomo.standardnotes.org/";
79-
_paq.push(['setTrackerUrl', u+'piwik.php']);
80-
_paq.push(['setSiteId', '6']);
81-
var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
82-
g.type='text/javascript'; g.async=true; g.defer=true; g.src=u+'piwik.js'; s.parentNode.insertBefore(g,s);
83-
})();
84-
(function() {
85-
var previousPageUrl = null;
86-
addEventListener("turbolinks:load", function(event) {
87-
if (previousPageUrl) {
88-
_paq.push(["setReferrerUrl", previousPageUrl]);
89-
_paq.push(["setCustomUrl", window.location.href]);
90-
_paq.push(["setDocumentTitle", document.title]);
91-
_paq.push(["trackPageView"]);
92-
}
93-
previousPageUrl = window.location.href;
94-
});
95-
})();
96-
</script>
97-
<!-- End Piwik Code -->
76+
<!-- Plausible -->
77+
<script defer data-domain="listed.to" src="https://plausible.standardnotes.com/js/plausible.js"></script>
78+
<!-- End Plausible Code -->
9879

9980
</head>
10081

config/routes.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,5 +90,7 @@
9090
get '/:post_token' => 'posts#show'
9191
get '/p/:post_token' => 'posts#show'
9292

93+
get '404', :to => 'application#page_not_found'
94+
9395
root 'usage#index'
9496
end

public/404.html

Lines changed: 0 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -3,55 +3,6 @@
33
<head>
44
<title>The page you were looking for doesn't exist (404)</title>
55
<meta name="viewport" content="width=device-width,initial-scale=1">
6-
<style>
7-
body {
8-
background-color: #EFEFEF;
9-
color: #2E2F30;
10-
text-align: center;
11-
font-family: arial, sans-serif;
12-
margin: 0;
13-
}
14-
15-
div.dialog {
16-
width: 95%;
17-
max-width: 33em;
18-
margin: 4em auto 0;
19-
}
20-
21-
div.dialog > div {
22-
border: 1px solid #CCC;
23-
border-right-color: #999;
24-
border-left-color: #999;
25-
border-bottom-color: #BBB;
26-
border-top: #B00100 solid 4px;
27-
border-top-left-radius: 9px;
28-
border-top-right-radius: 9px;
29-
background-color: white;
30-
padding: 7px 12% 0;
31-
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
32-
}
33-
34-
h1 {
35-
font-size: 100%;
36-
color: #730E15;
37-
line-height: 1.5em;
38-
}
39-
40-
div.dialog > p {
41-
margin: 0 0 1em;
42-
padding: 1em;
43-
background-color: #F7F7F7;
44-
border: 1px solid #CCC;
45-
border-right-color: #999;
46-
border-left-color: #999;
47-
border-bottom-color: #999;
48-
border-bottom-left-radius: 4px;
49-
border-bottom-right-radius: 4px;
50-
border-top-color: #DADADA;
51-
color: #666;
52-
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
53-
}
54-
</style>
556
</head>
567

578
<body>
@@ -61,7 +12,6 @@
6112
<h1>The page you were looking for doesn't exist.</h1>
6213
<p>You may have mistyped the address or the page may have moved.</p>
6314
</div>
64-
<p>If you are the application owner check the logs for more information.</p>
6515
</div>
6616
</body>
6717
</html>

public/robots.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,3 @@
55

66
User-agent: *
77
Sitemap: /sitemap.xml
8-
Disallow: /p/*

0 commit comments

Comments
 (0)