Enable reader mode

Various fixes to enable reader mode on most platforms. I tested on
firefox, google chrome, and microsoft edge, I don't have an iphone, so
let me know if it's still broken.
This commit is contained in:
Robin Malley 2020-05-19 20:13:30 -04:00
parent 2e735282ec
commit 03d4779129
3 changed files with 24 additions and 22 deletions

View File

@ -70,7 +70,7 @@ local grammar = P{
marked = V"spoiler" + V"bold" + V"italic" + V"underline" + V"heading" + V"strike" + V"spoiler2" + V"code", marked = V"spoiler" + V"bold" + V"italic" + V"underline" + V"heading" + V"strike" + V"spoiler2" + V"code",
plainline = (V"marked" + word)^0, plainline = (V"marked" + word)^0,
line = Cs(V"greentext" + V"pinktext" + V"plainline" + P"") * P"\n" / function(a) line = Cs(V"greentext" + V"pinktext" + V"plainline" + P"") * P"\n" / function(a)
return string.format("%s<br/>",a) return string.format("<p>%s",a)
end, end,
ending = C(P(1)^0) / sanitize, ending = C(P(1)^0) / sanitize,
chunk = V"line"^0 * V"plainline" * V"ending" chunk = V"line"^0 * V"plainline" * V"ending"

View File

@ -6,7 +6,7 @@ local escapes = {
['"'] = "&quot;", ['"'] = "&quot;",
["'"] = "&#39;", ["'"] = "&#39;",
--Kinda hacky --Kinda hacky
["\n"] = "<br/>", ["\n"] = "<p>",
} }
local esctbl = {} local esctbl = {}
for char,_ in pairs(escapes) do for char,_ in pairs(escapes) do
@ -18,5 +18,7 @@ local function sanitize(capture)
return escapes[capture] or capture return escapes[capture] or capture
end end
return function(text) return function(text)
return string.gsub(text,escapematch,sanitize) text = string.gsub(text,escapematch,sanitize)
--text = string.gsub(text,"\n\n","<p>")
return text
end end

View File

@ -2,33 +2,33 @@
<html lang="en"> <html lang="en">
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<title><%= title %></title> <meta name="author" content="<%= author %>">
<title><%- title %></title>
<link href="/_css/milligram.css" rel="stylesheet"> <link href="/_css/milligram.css" rel="stylesheet">
<link href="/_css/style.css" rel="stylesheet"> <link href="/_css/style.css" rel="stylesheet">
</head> </head>
<body class="container"> <body><main class="wrapper">
<main class="wrapper"> <nav>
<h1>
<a href="https://<%= domain %>"><%= domain %></a>/<a href="https://<%= domain %>/<%= idp %>"><%= idp %></a> <a href="https://<%= domain %>"><%= domain %></a>/<a href="https://<%= domain %>/<%= idp %>"><%= idp %></a>
</h1> </nav>
<% if owner then %> <% if owner then %>
<form action="https://<%= domain %>/_edit" method="get"><fieldset> <form action="https://<%= domain %>/_edit" method="get"><fieldset>
<input type="hidden" name="story" value="<%= idp %>"/> <input type="hidden" name="story" value="<%= idp %>"/>
<input type="submit" value="edit" class="button"/> <input type="submit" value="edit" class="button"/>
</fieldset></form> </fieldset></form>
<% end %> <% end %>
<h1 class="title"> <h2 class="title">
<%- title %> <%- title %>
</h1> </h2>
<h3>
<% if isanon then %> <% if isanon then %>
By Anonymous By Anonymous
<% else %> <% else %>
By <a href="https://<%= author %>.<%= domain %>"><%= author %></a> By <a href="https://<%= author %>.<%= domain %>"><%= author %></a>
<% end %> <% end %>
<article class="container content"> </h3>
<%- text %> <%- text %>
</article> </article>
</main> </main></body>
</body>
</html> </html>