Tons of changes, all for adding a RSS feed

main
Astoria 2 years ago
parent 37907e95cc
commit b206070606

@ -0,0 +1,85 @@
class Page
@file
@path
@link
@metadata
@@ADDTAGS = { :rbe => { html_open: "\<%=", html_close: "%\>" }, :rb => { html_open: "\<%", html_close: "%\>" } }
def initialize(path)
@path = path
@link = "https://broken-moon.net/" + path
begin
@file = File.readlines(path)
rescue
raise "Invalid page at " + path
end
if @file[0] == "+++\n"
@metadata = get_toml_meta
else
raise "No Metadata"
end
end
def get_date
if @metadata.has_key?("date")
return @metadata["date"]
else
return "1970.1.1"
end
end
def get_title
if @metadata.has_key?("title")
return @metadata["title"]
else
return "No title"
end
end
def get_description
if @metadata.has_key?("description")
return @metadata["description"]
else
return "No description"
end
end
def get_link
if @metadata.has_key?("link")
return @metadata["link"]
else
return @link
end
end
def get_path
return @path
end
def get_toml_meta
startIndex = @file.find_index("+++\n")
@file[startIndex] = ""
endIndex = @file.find_index("+++\n")
tomlString = @file[startIndex+1..endIndex-1].join
@file.slice!(startIndex, endIndex + 1)
# JANK AS SHIT, WILL HURT ME
return TOML.load(tomlString)
end
def render
case @metadata["format"]
when "markdown"
return Kramdown::Document.new(@file.join).to_html
when "erb"
return ERB.new(@file.join).result(binding)
when "bbcode"
return ERB.new(@file.join.concat("\n").gsub("\n[rb]", '[rb]').bbcode_to_html(false, @@ADDTAGS)).result(binding)
else
return @file
end
end
def get_feed_entry
return " <item>\n <title>" + get_title + "</title>\n <link>" + get_link + "</link>\n <description>" + get_description + "</description>\n </item>"
end
end

@ -0,0 +1,5 @@
+++
format = "bbcode"
+++
[b]Test[/b]
[rbe] "HAHAHHA" [/rbe]

@ -1,3 +1,8 @@
+++
date = "2021.08.18"
format = "markdown"
title = "Well, This is Awkward"
+++
# [Well, This is Awkward.](/news/wellThisIsAwkward)
So, been a good few months.

@ -0,0 +1,595 @@
:root {
--fg-col: #FFFFFF;
/*--main-col: #d2738a;*/
--main-col:#b4a999;
--grey-col: #CCCCCC;
--bg-col: #1f1710;
--ver: calc(95vh - 50px);
--ver-btm: 10vh;
--ver-upr: 18px;
--shade: linear-gradient(to top, rgba(31,23,16,1), rgba(31,23,16,0.8), rgba(31,23,16,0));
}
body {
background-repeat: no-repeat;
background-color: var(--bg-col);
background-size: cover;
background-attachment: fixed;
background-position: bottom left;
word-break: break-word;
display: grid;
grid-template-columns: auto;
gap: 20px;
}
ul {
list-style: none;
margin: 4px 0;
}
li {
margin: 4px 0;
}
img {
padding: 2px;
border: 3px double var(--main-col);
}
table {
padding: 2px;
margin: 20px 0 20px 0;
border: 1px solid var(--main-col);
}
th {
color: var(--fg-col);
font-weight: bold;
}
tr:nth-child(odd) {
background-color: #150f0a;
}
tr:nth-child(even) {
background-color: #392a1d;
}
input[type="submit" i] {
background: unset;
border: 3px double var(--main-col);
margin-left: 10px;
color: var(--main-col);
font-size: 1.5em;
}
.aside, .article, .section, .banner {
opacity: 0.9;
transition: 0.3s;
}
.banner {
border: none;
width: 240px;
max-width: 100%;
}
.banner:hover {
opacity: 1;
}
.bannerother, .bannergrave {
border: none;
height: 60px;
width: 240px;
max-width: 100%;
}
.bannergrave {
filter: grayscale(1);
transition: 0.3s;
}
.bannergrave:hover {
filter: grayscale(0);
}
.bannerlarge {
border: none;
max-width: 100%;
}
.imgnoborder {
max-width: 100%;
border: none;
}
.aside, .article, .section {
background: var(--bg-col);
padding: 10px;
border: 1px solid var(--main-col);
box-shadow: 3px 3px 2px var(--main-col);
}
.aside:hover, .article:hover, .section:hover {
opacity: 1;
box-shadow: 6px 6px 4px var(--main-col);
}
.aside {
width: 250px;
margin: 2px;
max-height: var(--ver);
align-self: start;
overflow-x: hidden;
position: sticky;
top: calc(2px + 8px);
}
.aside > ul {
padding-inline-start: 20px;
}
.aside > ul > ul {
padding-inline-start: 25px;
}
.asideitem {
list-style-image: url("../images/list.gif");
list-style-position: inside;
font-size: 1.2em;
}
.asidesubitem {
list-style-image: url("../images/listsmall.gif");
list-style-position: inside;
font-size: 1em;
}
.openaside {
display: none;
position: fixed !important;
height: 1.5em;
padding: 6px 0 0 0 !important;
width: 100%;
top: 0;
left: 0;
right: 0;
background: var(--bg-col);
border-bottom: 3px double var(--main-col) !important;
border-top: none !important;
border-left: none !important;
border-right: none !important;
text-align: center;
box-shadow: none !important;
z-index: 1;
}
.openaside a {
font-size: 1.2em;
letter-spacing: 8px;
margin-top: 4px;
}
.bottom {
height: var(--ver-btm);
width: 100%;
bottom: 0;
left: 0;
position: fixed;
background-image: var(--shade);
display: table;
pointer-events: none;
}
.bottomcell {
display: table-cell;
vertical-align: bottom;
text-align: center;
opacity: 0.7;
transition: 0.3s;
}
.bottomcell a {
pointer-events: all;
}
.bottomcell p {
pointer-events: all;
}
.bottomcell:hover {
opacity: 1;
}
.cell {
width: 45%;
text-align: center;
}
.cell > p {
height: 24px;
margin: 16px 0 0 0;
}
.cell > h3 {
height: 48px;
margin: 16px 0 0 0;
}
.mobilemenu {
width: 250px;
overflow-x: hidden;
margin-right: auto;
margin-left: auto;
}
.mobilemenu > ul {
text-align: left;
position: relative;
right: 9px;
}
.mobilemenu > ul > ul > p {
left: 25% !important;
}
.content {
margin-bottom: 5vh;
margin-top: 2px;
width: fit-content;
}
.article {
margin: 2px 20px 0 20px;
padding: 25px !important;
margin-top: 30px;
margin-bottom: 55px;
}
.article-headerless {
margin: 0 20px 55px 0 !important;
}
.section {
max-height: 50vh;
overflow: hidden;
position: relative;
}
.section1 {
margin: 20px 20px 20px 80px;
}
.section2 {
margin: 20px 80px 20px 20px;
}
.section3 {
margin: 20px 60px 20px 60px;
}
.homesection {
margin-bottom: 60px;
width: 540px;
text-align: center;
max-height: unset;
}
.homemessage, .homesubmessage {
font-style: italic;
}
.homemessage {
font-size: 2em;
}
.homesubmessage {
font-size: 1.2em;
}
.homesmallimg {
display: none;
}
.upperdirs {
width: 80%;
height: var(--ver-upr);
margin-bottom: 20px;
margin-left: auto;
margin-right: auto;
text-align: center;
}
.numlist {
display: table;
margin-bottom: 20px;
margin-left: auto;
margin-right: auto;
}
.seemore {
position: absolute;
bottom: 0;
width: calc(100% - 20px);
height: 60px;
background-image: var(--shade);
}
.seedate {
float: left;
margin-top: 40px;
}
.articledate {
float: left;
margin-top: 5px;
}
.seemorelink {
float: right;
margin-top: 40px;
}
.greyed {
color: var(--grey-col);
}
.archivereturn {
margin: 20px 60px 20px 60px;
display: table;
}
.search {
width: 25vw;
min-width: 300px;
}
.titlecol {
width: 65%;
}
.datecol {
width: 35%;
}
.nothinghere {
width: 50vw;
height: 10vh;
margin: 20px 10vw 0 10vw;
text-align: center;
}
.nothinghere > .notgood {
letter-spacing: 2px;
animation: notgood 4s ease-in-out infinite;
animation-play-state: running;
}
.nothingreturn {
position: absolute;
bottom: 0;
right: 0;
font-size: 1.2em;
padding: 6px;
}
.extlink {
background: url("../images/ext.gif") no-repeat;
background-position: right;
padding-right: 13px;
}
.leftimg, .rightimg, .centerimg {
filter: grayscale(1);
transition: 0.2s;
}
.leftimg:hover, .rightimg:hover, .centerimg:hover {
filter: none;
}
.leftimg, .rightimg {
max-width: 50%;
max-height: 25em;
display: block;
margin: 10px;
}
.leftimg {
float: left;
}
.rightimg {
float: right;
}
.centerimg {
max-width: 70%;
max-height: 30em;
display: block;
margin: 10px auto;
}
.quote {
display: inline-block;
margin: 5px;
color: var(--grey-col);
}
.quote:before {
content: "「";
color: var(--main-col);
letter-spacing: 10px;
}
.quote:after {
content: "」";
color: var(--main-col);
letter-spacing: 10px;
}
.scrollingcontentbtm {
margin-bottom: var(--ver-btm);
display: inline-block;
}
.blogbox {
position: relative;
right: 11px;
border: 1px solid var(--main-col);
margin-left: 20px;
margin-bottom: 10px;
}
.asidehometext {
font-size: 1.2em;
position: relative;
display: none;
text-align: center;
}
.asidebottomimage {
height: 30px;
max-width: 30px;
margin: 0 3px;
transition: 0.5s;
}
.asidebottomimage:hover {
box-shadow: var(--main-col) 1px 4px 5px;
}
.archivespan {
margin: 30px;
}
.codeblock {
font-family: 'pxplus_ibm_vga9regular', monospace;
border: 1px solid var(--main-col);
background-color: #1b1b1d;
color: #ffcccc;
font-size: 0.9em;
padding: 10px;
white-space: pre-wrap;
margin: 10px;
overflow-wrap: break-word;
word-break: break-all;
}
.largefont {
font-size: 2em;
}
.center {
text-align: center;
margin-left: auto;
margin-right: auto;
}
.arrow {
border: none;
padding: 2px 0 0 0;
}
.datetext {
text-align: center;
font-weight: bold;
}
.webring-panel {
width: fit-content;
margin-left: auto;
margin-right: auto;
}
.webring-text {
margin: 6px;
}
.webring-table {
margin-top: 0;
margin-bottom: 0;
}
@keyframes notgood {
0% {
letter-spacing: 2px;
}
50% {
letter-spacing: 4px;
}
100% {
letter-spacing: 2px;
}
}
@media (max-width: 900px) {
.aside > .asidehomeimage {
display: none;
}
.aside > .asidehometext {
display: block;
}
.aside {
width: 200px;
}
.content {
}
}
@media (max-height: 580px) {
.aside > .asidehomeimage {
display: none;
}
.aside > .asidehometext {
display: block;
}
}
@media (max-width: 850px) {
.homesection {
width: 220px;
}
.homelargeimg {
display: none;
}
.homesmallimg {
display: block;
}
}
@media (max-width: 660px) {
.aside {
display: none;
}
body { grid-template-columns: auto }
.openaside {
display: block;
}
body {
margin: 3em 8px 8px 8px;
}
.content {
margin-left: unset;
}
}
@media (max-width: 600px) {
.seedate {
display: none;
}
.seemorelink {
float: left;
}
.bottomcell > p {
font-size: 0.7em;
}
}

28
v5.rb

@ -3,27 +3,9 @@ require 'sinatra'
require 'erb'
require 'date'
require 'ruby-bbcode'
class Page
@path
@date
def initialize(path, date)
@path = path
@date = date
end
def setpath(path)
@path = path
end
def setdate(date)
@date = date
end
def getpath
return @path
end
def getdate
return @date
end
end
require 'toml'
require 'kramdown'
require './lib/page.rb'
get '/' do
erb :greetpage
@ -93,6 +75,10 @@ get '/contact' do
erb :contactpage
end
get '/feed' do
erb :feed, locals: {folders: ["media", "technology", "news"]}
end
not_found do
status 404
erb :oops

@ -1,12 +1,12 @@
<!DOCTYPE html>
<html lang="en">
<% title = request.path_info[1..-1].capitalize %>
<% title = title.slice(0..(title.index('/') - 1)) %>
<% page = Page.new("." + request.path_info) %>
<% title = page.get_title %>
<head>
<title><%= title %></title>
<meta name="description" content="broken-moon.net - <%= title %>" />
<meta name="keywords" content="<%= title.downcase %>" />
<meta property="og:url" content="http://broken-moon.net/<%= title.downcase %>" />
<meta name="keywords" content="<%= title %>" />
<meta property="og:url" content="http://broken-moon.net/<%= title %>" />
<meta property="og:title" content="<%= title %>" />
<%= erb :headerBoilerplate %>
</head>
@ -14,42 +14,11 @@
<%= erb :asidemenu %>
<div class="content">
<%= erb :blogbar, locals: {title: title} %>
<% addtags = { :rbe => { html_open: "\<%=", html_close: "%\>" }, :rb => { html_open: "\<%", html_close: "%\>" } } %>
<div class="article">
<% if File.exist?("." + request.path_info) && request.path_info.end_with?(".erb") %>
<%= ERB.new(File.read("." + request.path_info)).result(binding) %>
<% elsif File.exist?("." + request.path_info + ".erb") %>
<%= ERB.new(File.read("." + request.path_info + ".erb")).result(binding) %>
<% elsif File.exist?("." + request.path_info) && request.path_info.end_with?(".md") %>
<%= markdown(File.read("." + request.path_info)) %>
<% elsif File.exist?("." + request.path_info + ".md") %>
<%= markdown(File.read("." + request.path_info + ".md")) %>
<% elsif File.exist?("." + request.path_info) && request.path_info.end_with?(".bb") %>
<%= ERB.new(File.read("." + request.path_info).gsub("\n[rb]", '[rb]').bbcode_to_html(false, addtags) + "<br>").result(binding) %>
<% elsif File.exist?("." + request.path_info + ".bb") %>
<%= ERB.new(File.read("." + request.path_info + ".bb").gsub("\n[rb]", '[rb]').bbcode_to_html(false, addtags)+ "<br>").result(binding) %>
<% end %>
<% if File.exist?("." + request.path_info + ".meta") %>
<%= page.render %>
<div class="articledate">
<%= File.read("." + request.path_info + ".meta") %>
<%= page.get_date %>
</div>
<% elsif File.exist?("." + request.path_info + ".erb.meta") %>
<div class="articledate">
<%= File.read("." + request.path_info + ".erb.meta") %>
</div>
<% elsif File.exist?("." + request.path_info + ".md.meta") %>
<div class="articledate">
<%= File.read("." + request.path_info + ".md.meta") %>
</div>
<% elsif File.exist?("." + request.path_info + ".bb.meta") %>
<div class="articledate">
<%= File.read("." + request.path_info + ".bb.meta") %>
</div>
<% else %>
<div class="articledate">
1970.01.01
</div>
<% end %>
</div>
</div>
<%= erb :bottom %>

@ -1,16 +0,0 @@
<div class="section section<%= rand(1..3) %>">
<% if file.end_with?(".md") %>
<%= markdown(File.read(file)) %>
<% elsif file.end_with?(".erb") %>
<%= ERB.new(File.read(file)).result(binding) %>
<% elsif file.end_with?(".bb") %>
<% addtags = { :rbe => { html_open: "\<%=", html_close: "%\>" }, :rb => { html_open: "\<%", html_close: "%\>" } } %>
<%= ERB.new(File.read(file).gsub("\n[rb]", '[rb]').bbcode_to_html(false, addtags) + "<br>").result(binding) %>
<% end %>
<span class="seemore">
<b>
<span class="seedate"><%= date %></span>
</b>
<a class="seemorelink" href="/<%= file %>">Article Page</a>
</span>
</div>

@ -0,0 +1,34 @@
<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0">
<channel>
<title>Broken Moon Network</title>
<link>https://www.broken-moon.net</link>
<description>A personal project of Astoria.</description>
<% pageArray = Array.new %>
<% folders.each do |folder| %>
<% if Dir.exists? folder %>
<% contents = Dir.children("./" + folder) %>
<% if !contents.empty? %>
<% contents.each do |content| %>
<% begin %>
<% newPage = Page.new(folder + "/" + content) %>
<% rescue %>
<% puts "bad times at " + content %>
<% else %>
<% pageArray.push(newPage) %>
<% end %>
<% end %>
<% end %>
<% end %>
<% end %>
<% pageArray.sort_by! { |page| page.get_date } %>
<% pageArray.reverse.each do | page | %>
<%= page.get_feed_entry %>
<% end %>
</channel>
</rss>

@ -4,12 +4,12 @@
<% contents = Dir.children("./" + folder).grep(/#{searchquery}/) %>
<% if !contents.empty? %>
<% contents.each do |content| %>
<% if content.end_with?(".erb") || content.end_with?(".md") || content.end_with?(".bb") %>
<% if File.exists?("./" + folder + "/" + content + ".meta") %>
<% newPage = Page.new(folder + "/" + content, DateTime.parse(File.read("./" + folder + "/" + content + ".meta"), "%Y.%m.%d")) %>
<% else %>
<% newPage = Page.new(folder + "/" + content, DateTime.parse("1970.01.01", "%Y.%m.%d")) %>
<% end %>
<% begin %>
<% newPage = Page.new(folder + "/" + content) %>
<% rescue %>
<%# Do nothing LOLOL %>
<% puts "bad times at " + content %>
<% else %>
<% contentsArray.push(newPage) %>
<% end %>
<% end %>
@ -21,10 +21,16 @@
<%= erb :throwError, locals: {errorcode: "404", error: "No result", errordescriptor: "No pages matching " + searchquery, returntarget: origin} %>
<% end %>
<% contentsArray.sort_by! { |page| page.getdate } %>
<% contentsArray.sort_by! { |page| page.get_date } %>
<% contentsArray.reverse.each do |content| %>
<% if content.getpath.end_with?(".erb") || content.getpath.end_with?(".md") || content.getpath.end_with?(".bb") %>
<%= erb :blogwindow, locals: {file: "./" + content.getpath, date: content.getdate.strftime("%Y.%m.%d")} %>
<% end %>
<div class="section section<%= rand(1..3) %>">
<%= content.render %>
<span class="seemore">
<b>
<span class="seedate"><%= content.get_date %></span>
</b>
<a class="seemorelink" href="/<%= content.get_path %>">Article Page</a>
</span>
</div>
<% end %>

@ -0,0 +1,11 @@
<meta property="og:image" content="/images/banner.gif" />
<meta property="og:image:type" content="image/gif" />
<meta property="og:image:width" content="88" />
<meta property="og:image:height" content="31" />
<meta property="og:type" content="website" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="icon" type="image/gif" href="favicon.gif" />
<link rel="stylesheet" href="/css/mobileMenu.css" />
<link rel="stylesheet" href="/css/noscroll.css" />
<link rel="stylesheet" href="/css/fonts.css" />
<%# Work on this later %>

@ -6,7 +6,7 @@
<meta name="keywords" content="menu" />
<meta property="og:url" content="http://broken-moon.net/mobile-menu" />
<meta property="og:title" content="Mobile Menu" />
<%= erb :headerBoilerplate %>
<%= erb :menuBoilerplate %>
</head>
<body>
<div class="mobilemenu">

Loading…
Cancel
Save