commit b537e4cb4021aa1da2540c800c1274c5cb14dc55
parent e8315f073d6ef3a4c806ff7f85901948f786e42d
Author: Ryan Jeffrey <ryan@ryanmj.xyz>
Date: Mon, 21 Feb 2022 22:17:17 -0800
New HTML and CSS, better updating files, properly removes files
Diffstat:
7 files changed, 88 insertions(+), 120 deletions(-)
diff --git a/app/assets/stylesheets/application.css b/app/assets/stylesheets/application.css
@@ -24,14 +24,14 @@ main {
/* unvisited link */
a:link {
color: var(--fg-color1);
- text-shadow: 0 0 4px var(--fg-color1);
+ text-shadow: 0 0 3px var(--fg-color1);
text-decoration: none;
}
/* visited link */
a:visited {
color: var(--emph-color);
- text-shadow: 0 0 4px var(--emph-color);
+ text-shadow: 0 0 3px var(--emph-color);
}
/* mouse over link */
@@ -42,23 +42,21 @@ a:hover, a:active {
/* Mostly org titles. */
h1 {
color: var(--header-color);
- text-shadow: 0 0 4px var(--header-color);
+ text-shadow: 0 0 3px var(--header-color);
}
h2 {
margin: 0 auto;
padding: 0;
color: var(--header-color2);
- text-shadow: 0 0 4px var(--header-color2);
- text-shadow: 0 0 4px
+ text-shadow: 0 0 3px var(--header-color2);
}
h3 {
margin: 0 auto;
padding: 0;
color: var(--fg-color1);
- text-shadow: 0 0 4px var(--fg-color1);
- text-shadow: 0 0 4px
+ text-shadow: 0 0 3px var(--fg-color1);
}
h4 {
@@ -66,7 +64,7 @@ h4 {
margin: 0;
margin-top: 0;
color: var(--fg-color2);
- text-shadow: 0 0 4px var(--fg-color2);
+ text-shadow: 0 0 3px var(--fg-color2);
font-size: 0.8em;
}
@@ -75,7 +73,7 @@ h5 {
margin: 0;
margin-top: 0;
color: var(--header-color3);
- text-shadow: 0 0 4px var(--header-color3);
+ text-shadow: 0 0 3px var(--header-color3);
font-size: 0.8em;
}
@@ -84,7 +82,7 @@ h6 {
margin: 0;
margin-top: 0;
color: var(--header-color4);
- text-shadow: 0 0 4px var(--header-color4);
+ text-shadow: 0 0 3px var(--header-color4);
font-size: 0.8em;
}
nav {
@@ -121,82 +119,35 @@ nav img {
max-width: 4em;
}
-
-@media (min-width: 1200px) {
- nav {
- float: left;
- width: 10%;
- position: fixed;
- text-align: left;
- font-size: large;
- }
- nav::before {
- content: "Links";
- text-align: center;
- display: block;
- font-size: large;
- color: violet;
- text-decoration: underline;
- margin: 0.5em;
- }
- nav li {
- display: block;
- text-align: center;
- margin: 0.5em auto;
- }
- nav img {
- max-width: 60%;
- }
-}
-
-
-.twin {
+.ewin {
width: 100%;
- background-color: rgba(0, 0, 0, 0.85);
-
-}
-
-.tcontent {
- margin: 0 auto;
- padding: 0;
}
-
-.twin p, span {
+p {
margin: 0 auto;
+ margin-top: 2em;
padding: 0;
- color: var(--white);
- text-shadow: 0 0 4px var(--white);
-}
-
-p.ls {
- white-space: pre-wrap;
-}
-
-.cat p {
- white-space: normal;
- margin-bottom: 1.5em;
-}
-
-
-h2 {
- color: var(--spring_green);
- font-size: 26pt;
+ color: var(--fg-color);
+ text-shadow: 0 0 3px var(--fg-color);
}
-
+
body {
border: 1.5em solid transparent;
border-image: url(/res/2008.webp) 19 12 round;
padding: 0;
/* positioning */
margin: 0 auto;
- background-color: var(--bg-color);
background-repeat: no-repeat; /* Do not repeat the image */
background-size: cover; /* Resize the background image to cover the entire container */
font-family: monospace;
-webkit-font-smoothing: none;
-moz-font-smoothing: never;
color: var(--fg-color);
+ background-color: black;
+}
+
+html {
+ z-index: 10;
}
footer {
@@ -226,16 +177,17 @@ tr:first-child td {
}
li {
- color: var(--white);
- text-shadow: 0 0 4px var(--white);
+ color: var(--fg-color);
+ text-shadow: 0 0 3px var(--fg-color);
}
th, td {
margin: 0 auto;
padding: 0;
- text-shadow: 0 0 4px var(--fg-color);
+ text-shadow: 0 0 3px var(--fg-color);
}
th {
color: var(--header-color2);
+ text-shadow: 0 0 3px var(--header-color2);
}
diff --git a/app/javascript/backs.ts b/app/javascript/backs.ts
@@ -11,16 +11,9 @@ export function initBackground() {
newCanvas.style['left'] = '0';
newCanvas.style['right'] = '0';
newCanvas.style['top'] = '0';
- newCanvas.style['z-index' as any] = '-1';
+ newCanvas.style.zIndex = '-100';
newCanvas.width = window.innerWidth;
newCanvas.height = window.innerHeight;
- document.body.style.backgroundColor = "black";
-
- let tmpCanvas = document.createElement('canvas');
- let tmpContext = tmpCanvas.getContext('2d');
- tmpCanvas.width = window.innerWidth;
- tmpCanvas.height = window.innerHeight;
- document.body.style.backgroundColor = "black";
document.body.appendChild(newCanvas);
diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb
@@ -14,7 +14,6 @@
<%= stylesheet_link_tag "application", "data-turbo-track": "reload" %>
<meta name="author" content="Ryan Jeffrey" />
<link rel="shortcut icon" type="image/x-icon" href="favicon32x32.ico">
- <%= javascript_include_tag 'generated/movementInSquares', type: 'module', integrity: true %>
</head>
<body>
<nav>
diff --git a/app/views/posts/blog_index.html.erb b/app/views/posts/blog_index.html.erb
@@ -1,2 +1,12 @@
-<h1>Posts#blog_index</h1>
-<p>Find me in app/views/posts/blog_index.html.erb</p>
+<div class="ewin">
+ <ul>
+ <li><a href="/">..</a></li>
+ <% @posts.each do |post| %>
+ <li>
+ <a href="/posts/<%= post.url %>">
+ <%= post.title %>
+ </a>
+ </li>
+ <% end %>
+ </ul>
+</div>
diff --git a/app/views/posts/index.html.erb b/app/views/posts/index.html.erb
@@ -1,10 +1,22 @@
-<div class="twin">
- <div style="tcontent">
- </div>
- <div id="content">
- <hr class="prompt-break">
- <span class="prompt1">ryan</span><span class="prompt2">@</span><span class="prompt3">themainframe</span><span class="prompt4"></span> <span>cat </span>
- <div class="cat">
- </div>
- </div>
+<div class="ewin">
+ <h3>Navigation</h3>
+ <ul>
+ <li><a href="/posts">Posts</a></li>
+ <% @posts.each do |post| %>
+ <li>
+ <a href="/<%= post.url %>">
+ <%= post.title %>
+ </a>
+ </li>
+ <% end %>
+ </ul>
+</div>
+<div class="ewin">
+ <h3>Some cool peeps to check out.</h3>
+
+ <ul>
+ <li><a href="https://kylemcd.xyz">My Friend Kyle's Blog</a></li>
+ <li>Xah Lee's Blog (G©©g£€ it, I will not link to it becasue no https)</li>
+ <li><a href="https://lukesmith.xyz">Luke Smith</a></li>
+ </ul>
</div>
diff --git a/app/views/posts/show.html.erb b/app/views/posts/show.html.erb
@@ -1,11 +1,3 @@
-<div class="twin">
- <div style="tcontent">
- </div>
- <div id="content">
- <hr class="prompt-break">
- <span class="prompt1">ryan</span><span class="prompt2">@</span><span class="prompt3">themainframe</span><span class="prompt4"></span> <span>cat <%= @post.url %></span>
- <div class="cat">
+<div class="ewin">
<%= @post.body.html_safe %>
- </div>
- </div>
</div>
diff --git a/config/application.rb b/config/application.rb
@@ -6,7 +6,7 @@ require 'pathname'
# Require the gems listed in Gemfile, including any gems
# you've limited to :test, :development, or :production.
Bundler.require(*Rails.groups)
-
+# <%= javascript_include_tag 'generated/movementInSquares', type: 'module', integrity: true %>
# Has to be a function because Rails.root isn't defined for constant.
def org_dir
"#{Rails.root}/app/orgs"
@@ -37,12 +37,26 @@ def remove_org_from_db(file_path)
dir_name = File.dirname(get_org_path file_path)
dir_name = dir_name == '.' ? '' : dir_name
url = CGI.escape(File.basename(file_path, '.*'))
- begin
- post = Post.where(url: url, where: dir_name).sole
- post.destroy
- rescue => error
- # Nothing to destroy
- end
+ post = Post.find_by(url: url, where: dir_name)
+ post.destroy if post
+end
+
+def update_org_db(file_path)
+ # Check to see if we're actually getting an org file.
+ return if File.extname(file_path) != '.org'
+
+ # TODO get a description
+ title = org_get_title file_path
+ dir_name = File.dirname(get_org_path file_path)
+ dir_name = dir_name == '.' ? '' : dir_name
+ url = CGI.escape(File.basename(file_path, '.*'))
+ # Get the post.
+ post = Post.find_by(url: url, where: where)
+ return if not post
+ # Reset content and title.
+ post.body = Orgmode::Parser.new(File.read(file_path)).to_html
+ post.title = title
+ # TODO add more rescues for different errors
end
def add_org_to_db(file_path)
@@ -54,19 +68,15 @@ def add_org_to_db(file_path)
dir_name = File.dirname(get_org_path file_path)
dir_name = dir_name == '.' ? '' : dir_name
url = CGI.escape(File.basename(file_path, '.*'))
- begin
- post = Post.where(url: url, where: where).sole
- # Reset content and title.
- post.body = Orgmode::Parser.new(File.read(file_path)).to_html
- post.title = title
+ # Update org if it exists.
+ post = Post.find_by(url: url, where: dir_name)
+ return update_org_db(post) if post
# TODO add more rescues for different errors
- rescue => error
- # File does not exist, create it.
- Post.new(title: title, description: '',
- where: dir_name,
- url: url,
- body: Orgmode::Parser.new(File.read(file_path)).to_html).save
- end
+ # File does not exist, create it.
+ Post.new(title: title, description: '',
+ where: dir_name,
+ url: url,
+ body: Orgmode::Parser.new(File.read(file_path)).to_html).save
end
module Site
@@ -82,7 +92,7 @@ module Site
config.after_initialize do
# Do change in orgs file.
listener = Listen.to(org_dir) do |modified, added, removed|
- modified.each { |x| add_org_to_db x }
+ modified.each { |x| update_org_db x }
added.each { |x| add_org_to_db x }
removed.each { |x| remove_org_from_db x }
end