Format files and trim trailing whitespace

This commit is contained in:
Omar Roth 2019-03-23 14:05:13 -05:00
parent ce4b07d7d7
commit 0c6cede287
16 changed files with 101 additions and 101 deletions

View file

@ -965,8 +965,8 @@ post "/login" do |env|
end
if cookie.extension
cookie.extension = cookie.extension.not_nil!.gsub(".youtube.com", host)
cookie.extension = cookie.extension.not_nil!.gsub("Secure; ", "")
cookie.extension = cookie.extension.not_nil!.gsub(".youtube.com", host)
cookie.extension = cookie.extension.not_nil!.gsub("Secure; ", "")
end
env.response.cookies << cookie
end
@ -2569,8 +2569,8 @@ get "/api/v1/stats" do |env|
next statistics.to_json
end
statistics.to_json
end
statistics.to_json
end
get "/api/v1/captions/:id" do |env|
locale = LOCALES[env.get("preferences").as(Preferences).locale]?
@ -2613,8 +2613,8 @@ get "/api/v1/captions/:id" do |env|
end
end
next response
end
next response
end
env.response.content_type = "text/vtt"
@ -2723,7 +2723,7 @@ get "/api/v1/comments/:id" do |env|
reddit_thread = JSON.parse(reddit_thread.to_json).as_h
reddit_thread["comments"] = JSON.parse(comments.to_json)
next reddit_thread.to_json
next reddit_thread.to_json
else
response = {
"title" => reddit_thread.title,
@ -2731,10 +2731,10 @@ get "/api/v1/comments/:id" do |env|
"contentHtml" => content_html,
}
next response.to_json
end
next response.to_json
end
end
end
get "/api/v1/insights/:id" do |env|
locale = LOCALES[env.get("preferences").as(Preferences).locale]?
@ -2821,8 +2821,8 @@ get "/api/v1/insights/:id" do |env|
"graphData" => graph_data,
}
next response.to_json
end
next response.to_json
end
get "/api/v1/videos/:id" do |env|
locale = LOCALES[env.get("preferences").as(Preferences).locale]?
@ -3027,8 +3027,8 @@ get "/api/v1/videos/:id" do |env|
end
end
video_info
end
video_info
end
get "/api/v1/trending" do |env|
locale = LOCALES[env.get("preferences").as(Preferences).locale]?
@ -3075,8 +3075,8 @@ get "/api/v1/trending" do |env|
end
end
videos
end
videos
end
get "/api/v1/popular" do |env|
locale = LOCALES[env.get("preferences").as(Preferences).locale]?
@ -3105,8 +3105,8 @@ get "/api/v1/popular" do |env|
end
end
videos
end
videos
end
get "/api/v1/top" do |env|
locale = LOCALES[env.get("preferences").as(Preferences).locale]?
@ -3148,8 +3148,8 @@ get "/api/v1/top" do |env|
end
end
videos
end
videos
end
get "/api/v1/channels/:ucid" do |env|
locale = LOCALES[env.get("preferences").as(Preferences).locale]?
@ -3353,8 +3353,8 @@ get "/api/v1/channels/:ucid" do |env|
end
end
channel_info
end
channel_info
end
["/api/v1/channels/:ucid/videos", "/api/v1/channels/videos/:ucid"].each do |route|
get route do |env|
@ -3421,9 +3421,9 @@ get "/api/v1/channels/:ucid" do |env|
end
end
result
end
result
end
end
["/api/v1/channels/:ucid/latest", "/api/v1/channels/latest/:ucid"].each do |route|
get route do |env|
@ -3470,9 +3470,9 @@ get "/api/v1/channels/:ucid" do |env|
end
end
response
end
response
end
end
["/api/v1/channels/:ucid/playlists", "/api/v1/channels/playlists/:ucid"].each do |route|
get route do |env|
@ -3536,9 +3536,9 @@ get "/api/v1/channels/:ucid" do |env|
end
end
response
end
response
end
end
get "/api/v1/channels/search/:ucid" do |env|
locale = LOCALES[env.get("preferences").as(Preferences).locale]?
@ -3637,8 +3637,8 @@ get "/api/v1/channels/search/:ucid" do |env|
end
end
response
end
response
end
get "/api/v1/search" do |env|
locale = LOCALES[env.get("preferences").as(Preferences).locale]?
@ -3762,8 +3762,8 @@ get "/api/v1/search" do |env|
end
end
response
end
response
end
get "/api/v1/playlists/:plid" do |env|
locale = LOCALES[env.get("preferences").as(Preferences).locale]?
@ -3862,8 +3862,8 @@ get "/api/v1/playlists/:plid" do |env|
}.to_json
end
response
end
response
end
get "/api/v1/mixes/:rdid" do |env|
locale = LOCALES[env.get("preferences").as(Preferences).locale]?
@ -4444,7 +4444,7 @@ error 500 do |env|
<a href="https://github.com/omarroth/invidious/issues">
here
</a>
or send an email to
or send an email to
<a href="mailto:omarroth@protonmail.com">
omarroth@protonmail.com</a>.
END_HTML

View file

@ -308,13 +308,13 @@ def template_youtube_comments(comments, locale)
<p>
<b>
<a class="#{child["authorIsChannelOwner"] == true ? "channel-owner" : ""}" href="#{child["authorUrl"]}">#{child["author"]}</a>
</b>
</b>
<p style="white-space:pre-wrap">#{child["contentHtml"]}</p>
<span title="#{Time.unix(child["published"].as_i64).to_s(translate(locale, "%A %B %-d, %Y"))}">#{translate(locale, "`x` ago", recode_date(Time.unix(child["published"].as_i64), locale))} #{child["isEdited"] == true ? translate(locale, "(edited)") : ""}</span>
|
<a href="https://www.youtube.com/watch?v=#{comments["videoId"]}&lc=#{child["commentId"]}" title="#{translate(locale, "Youtube permalink of the comment")}">[YT]</a>
|
<i class="icon ion-ios-thumbs-up"></i> #{number_with_separator(child["likeCount"])}
|
<i class="icon ion-ios-thumbs-up"></i> #{number_with_separator(child["likeCount"])}
END_HTML
if child["creatorHeart"]?
@ -372,8 +372,8 @@ def template_reddit_comments(root, locale)
content = <<-END_HTML
<p>
<a href="javascript:void(0)" onclick="toggle_parent(this)">[ - ]</a>
<b><a href="https://www.reddit.com/user/#{author}">#{author}</a></b>
<a href="javascript:void(0)" onclick="toggle_parent(this)">[ - ]</a>
<b><a href="https://www.reddit.com/user/#{author}">#{author}</a></b>
#{translate(locale, "`x` points", number_with_separator(score))}
#{translate(locale, "`x` ago", recode_date(child.created_utc, locale))}
</p>

View file

@ -62,7 +62,7 @@ class FilteredCompressHandler < Kemal::Handler
call_next env
{% else %}
request_headers = env.request.headers
if request_headers.includes_word?("Accept-Encoding", "gzip")
env.response.headers["Content-Encoding"] = "gzip"
env.response.output = Gzip::Writer.new(env.response.output, sync_close: true)
@ -70,7 +70,7 @@ class FilteredCompressHandler < Kemal::Handler
env.response.headers["Content-Encoding"] = "deflate"
env.response.output = Flate::Writer.new(env.response.output, sync_close: true)
end
call_next env
{% end %}
end

View file

@ -300,7 +300,7 @@ def generate_captcha(key, db)
clock_svg = <<-END_SVG
<svg viewBox="0 0 100 100" width="200px">
<circle cx="50" cy="50" r="45" fill="#eee" stroke="black" stroke-width="2"></circle>
<text x="69" y="20.091" text-anchor="middle" fill="black" font-family="Arial" font-size="10px"> 1</text>
<text x="82.909" y="34" text-anchor="middle" fill="black" font-family="Arial" font-size="10px"> 2</text>
<text x="88" y="53" text-anchor="middle" fill="black" font-family="Arial" font-size="10px"> 3</text>

View file

@ -64,7 +64,7 @@
<%= rendered "components/item" %>
<% end %>
<% end %>
</div>
</div>
<div class="pure-g h-box">
<div class="pure-u-1 pure-u-md-1-5">

View file

@ -1,4 +1,4 @@
<video style="outline:none;width:100%" playsinline poster="<%= thumbnail %>" title="<%= HTML.escape(video.title) %>"
<video style="outline:none;width:100%" playsinline poster="<%= thumbnail %>" title="<%= HTML.escape(video.title) %>"
id="player" class="video-js"
onmouseenter='this["data-title"]=this["title"];this["title"]=""'
onmouseleave='this["title"]=this["data-title"];this["data-title"]=""'
@ -152,7 +152,7 @@ player.on('error', function(event) {
}
player.currentTime(currentTime);
player.playbackRate(playbackRate);
if (!paused) {
player.play();
}
@ -192,7 +192,7 @@ var bpb = player.getChild('bigPlayButton');
if (bpb) {
bpb.hide();
player.ready(function() {
new Promise(function(resolve, reject) {
setTimeout(() => resolve(1), 1);

View file

@ -1,14 +1,14 @@
<% if user %>
<% if subscriptions.includes? ucid %>
<p>
<a id="subscribe" onclick="unsubscribe()" class="pure-button pure-button-primary"
<a id="subscribe" onclick="unsubscribe()" class="pure-button pure-button-primary"
href="/subscription_ajax?action_remove_subscriptions=1&c=<%= ucid %>&referer=<%= env.get("current_page") %>">
<b><%= translate(locale, "Unsubscribe") %> | <%= sub_count_text %></b>
</a>
</p>
<% else %>
<p>
<a id="subscribe" onclick="subscribe()" class="pure-button pure-button-primary"
<a id="subscribe" onclick="subscribe()" class="pure-button pure-button-primary"
href="/subscription_ajax?action_create_subscription_to_channel=1&c=<%= ucid %>&referer=<%= env.get("current_page") %>">
<b><%= translate(locale, "Subscribe") %> | <%= sub_count_text %></b>
</a>
@ -16,7 +16,7 @@
<% end %>
<% else %>
<p>
<a id="subscribe" class="pure-button pure-button-primary"
<a id="subscribe" class="pure-button pure-button-primary"
href="/login?referer=<%= env.get("current_page") %>">
<b><%= translate(locale, "Login to subscribe to `x`", author) %></b>
</a>

View file

@ -4,13 +4,13 @@ if (subscribe_button.getAttribute('onclick')) {
}
function subscribe(timeouts = 0) {
subscribe_button = document.getElementById("subscribe");
subscribe_button = document.getElementById("subscribe");
if (timeouts > 10) {
console.log("Failed to subscribe.");
return;
}
var url = "/subscription_ajax?action_create_subscription_to_channel=1&c=<%= ucid %>&referer=<%= env.get("current_page") %>";
var xhr = new XMLHttpRequest();
xhr.responseType = "json";
@ -21,7 +21,7 @@ function subscribe(timeouts = 0) {
var fallback = subscribe_button.innerHTML;
subscribe_button.onclick = unsubscribe;
subscribe_button.innerHTML = '<b><%= translate(locale, "Unsubscribe").gsub("'", "\\'") %> | <%= sub_count_text %></b>'
xhr.onreadystatechange = function() {
if (xhr.readyState == 4) {
if (xhr.status != 200) {
@ -30,7 +30,7 @@ function subscribe(timeouts = 0) {
}
}
}
xhr.ontimeout = function() {
console.log("Subscribing timed out.");
@ -39,8 +39,8 @@ function subscribe(timeouts = 0) {
}
function unsubscribe(timeouts = 0) {
subscribe_button = document.getElementById("subscribe");
subscribe_button = document.getElementById("subscribe");
if (timeouts > 10) {
console.log("Failed to subscribe");
return;

View file

@ -20,7 +20,7 @@
</label>
<input type="file" id="import_youtube" name="import_youtube">
</div>
<div class="pure-control-group">
<label for="import_freetube"><%= translate(locale, "Import FreeTube subscriptions (.db)") %></label>
<input type="file" id="import_freetube" name="import_freetube">
@ -35,7 +35,7 @@
<label for="import_newpipe"><%= translate(locale, "Import NewPipe data (.zip)") %></label>
<input type="file" id="import_newpipe" name="import_newpipe">
</div>
<div class="pure-controls">
<button type="submit" class="pure-button pure-button-primary"><%= translate(locale, "Import") %></button>
</div>

View file

@ -10,13 +10,13 @@
<title><%= HTML.escape(video.title) %> - Invidious</title>
<style>
#player {
position: fixed;
right: 0;
position: fixed;
right: 0;
bottom: 0;
min-width: 100%;
min-width: 100%;
min-height: 100%;
width: auto;
height: auto;
width: auto;
height: auto;
z-index: -100;
}
</style>

View file

@ -19,4 +19,4 @@
<%= rendered "components/item" %>
<% end %>
<% end %>
</div>
</div>

View file

@ -31,7 +31,7 @@
<%= rendered "components/item" %>
<% end %>
<% end %>
</div>
</div>
<div class="pure-g h-box">
<div class="pure-u-1 pure-u-md-1-5">

View file

@ -5,15 +5,15 @@
<div class="h-box">
<%= Markdown.to_html(<<-END_PRIVACY_POLICY
## Privacy
This document concerns what data you provide to this website, the purpose of the data, how the data is stored, and how the data can be removed.
### Data you directly provide
Data that you provide to the website for the purpose of the site's operation (for example: an account name, account password, or channel subscription) will be stored in the website's database until the user decides to remove it. This data will not be intentionally shared with anyone or anything.
Information stored about a registered user is limited to:
- a list of session tokens for remaining logged in across devices
- the last time an account was updated (to provide accurate notifications)
- a list of video IDs identifying notifications from a user's subscriptions
@ -23,51 +23,51 @@
- a hashed password if applicable (not present on google accounts)
- a randomly generated token for providing an RSS feed of a user's subscriptions
- a list of video IDs identifying watched videos
The above list reflects [this code](https://github.com/omarroth/invidious/blob/master/src/invidious/users.cr#L14-L51).
Users can clear their watch history using the [clear watch history](/clear_watch_history) page.
If a user is logged in with a Google account, no password will ever be stored. This website uses the session token provided by Google to identify a user, but does not store the information required to make requests on a user's behalf without their knowledge or consent.
### Data you passively provide
When you request any resource from this website (for example: a page, a font, an image, or an API endpoint) information about the request may be logged.
Information about a request is limited to:
- the time the request was made
- the status code of the response
- the method of the request
- the requested URL
- how long it took to complete the request.
No identifying information is logged, such as the visitor's cookie, user-agent, or IP address. Here are a couple lines to serve as an example:
```
2019-01-19 16:37:47 +00:00 200 GET /api/v1/comments/xrlETJYzH-c?format=html&hl=en-US 1345.88ms
2019-01-19 16:37:53 +00:00 200 GET /vi/r5P-f5arPXE/maxres.jpg 1085.41ms
2019-01-19 16:37:54 +00:00 200 GET /watch 7.04ms
```
This website does not store the visitor's user-agent or IP address and does not use fingerprinting, advertisements, or tracking of any form.
This website provides links to googlevideo.com to provide audio and video playback. googlevideo.com is owned by Google and is subject to their [privacy policy](https://policies.google.com/privacy).
### Data stored in your browser
This website uses browser cookies to authenticate registered users. This data consists of:
- An account token to keep you logged into the website between visits, which is sent when any page is loaded while you are logged in
This website also provides an option to store site preferences, such as the theme or locale, without an account. Using this feature will store a cookie in the visitor's browser containing their preferences. This cookie is sent on every request and does not contain any identifying information.
You can remove this data from your browser by logging out of this website, or by using your browser's cookie-related controls to delete the data.
### Removal of data
To remove data stored in your browser, you can log out of the website, or you can use your browser's cookie-related controls to delete the data.
To remove data that has been stored in the website's database, you can use the [delete my account](/delete_account) page.
END_PRIVACY_POLICY
)

View file

@ -8,7 +8,7 @@
<%= rendered "components/item" %>
<% end %>
<% end %>
</div>
</div>
<div class="pure-g h-box">
<div class="pure-u-1 pure-u-md-1-5">

View file

@ -116,7 +116,7 @@
<div class="pure-u-1 pure-u-md-1-3">
<i class="icon ion-logo-usd"></i>
<a href="https://liberapay.com/omarroth">Liberapay</a>
/
/
<a href="https://patreon.com/omarroth">Patreon</a>
</div>
<div class="pure-u-1 pure-u-md-1-3">
@ -124,12 +124,12 @@
<a rel="jslicense" href="/licenses">
<%= translate(locale, "View JavaScript license information.") %>
</a>
/
/
<i class="icon ion-ios-paper"></i>
<a href="/privacy">
<%= translate(locale, "View privacy policy.") %>
</a>
</div>
</div>
<div class="pure-u-1 pure-u-md-1-3">
<i class="icon ion-logo-github"></i>
<%= translate(locale, "Current version: ") %> <%= CURRENT_VERSION %>-<%= CURRENT_COMMIT %>

View file

@ -18,7 +18,7 @@
<meta name="twitter:url" content="<%= host_url %>/watch?v=<%= video.id %>">
<meta name="twitter:title" content="<%= HTML.escape(video.title) %>">
<meta name="twitter:description" content="<%= description %>">
<meta name="twitter:image" content="/vi/<%= video.id %>/hqdefault.jpg">
<meta name="twitter:image" content="<%= host_url %>/vi/<%= video.id %>/maxres.jpg">
<meta name="twitter:player" content="<%= host_url %>/embed/<%= video.id %>">
<meta name="twitter:player:width" content="1280">
<meta name="twitter:player:height" content="720">
@ -33,7 +33,7 @@
<div class="h-box">
<h1>
<%= HTML.escape(video.title) %>
<%= HTML.escape(video.title) %>
<% if params[:listen] %>
<a title="<%=translate(locale, "Video mode")%>" href="/watch?<%= env.params.query %>&listen=0">
<i class="icon ion-ios-videocam"></i>
@ -53,7 +53,7 @@
<div class="pure-u-1 pure-u-md-1-5">
<div class="h-box">
<p><a href="https://www.youtube.com/watch?v=<%= video.id %>"><%= translate(locale, "Watch video on Youtube") %></a></p>
<form class="pure-form pure-form-stacked" action="/latest_version" method="get" rel="noopener" target="_blank">
<div class="pure-control-group">
<label for="download_widget"><%= translate(locale, "Download as: ") %></label>
@ -150,7 +150,7 @@
<% if params[:related_videos] %>
<div class="h-box">
<% if !rvs.empty? %>
<div id="continue" <% if plid %>style="display:none"<% end %>>
<div class="pure-control-group">
@ -187,7 +187,7 @@
<script>
<% if !rvs.empty? && !plid && params[:continue] %>
player.on('ended', function() {
location.assign("/watch?v="
location.assign("/watch?v="
+ "<%= rvs.select { |rv| rv["id"]? }[0]?.try &.["id"] %>"
+ "&continue=1"
<% if params[:listen] %>
@ -206,7 +206,7 @@ player.on('ended', function() {
function continue_autoplay(target) {
if (target.checked) {
player.on('ended', function() {
location.assign("/watch?v="
location.assign("/watch?v="
+ "<%= rvs.select { |rv| rv["id"]? }[0]?.try &.["id"] %>"
+ "&continue=1"
<% if params[:listen] %>
@ -270,10 +270,10 @@ function get_playlist(timeouts = 0) {
if (xhr.readyState == 4) {
if (xhr.status == 200) {
playlist.innerHTML = xhr.response.playlistHtml;
if (xhr.response.nextVideo) {
player.on('ended', function() {
location.assign("/watch?v="
location.assign("/watch?v="
+ xhr.response.nextVideo
+ "&list=<%= plid %>"
<% if params[:listen] %>
@ -355,7 +355,7 @@ function get_reddit_comments(timeouts = 0) {
contentHtml: xhr.response.contentHtml
});
} else {
<% if preferences && preferences.comments[1] == "youtube" %>
<% if preferences && preferences.comments[1] == "youtube" %>
get_youtube_comments();
<% else %>
comments.innerHTML = fallback;
@ -416,7 +416,7 @@ function get_youtube_comments(timeouts = 0) {
comments.innerHTML = "";
}
} else {
<% if preferences && preferences.comments[1] == "youtube" %>
<% if preferences && preferences.comments[1] == "youtube" %>
get_youtube_comments();
<% else %>
comments.innerHTML = "";