From bfd8209ad0d80b5027bea8a1a095dadc8bffdc61 Mon Sep 17 00:00:00 2001 From: mms Date: Sun, 5 Jan 2025 22:34:55 +0100 Subject: feat(new): splash page in progress --- new/splash/assets/images/background.png | Bin 0 -> 3909 bytes new/splash/assets/images/buttons/org.dillo.gif | Bin 0 -> 1899 bytes new/splash/assets/images/buttons/org.freebsd.gif | Bin 0 -> 999 bytes new/splash/assets/images/new.gif | Bin 0 -> 141 bytes new/splash/bin/build.rb | 12 +- new/splash/lib/splash/builder.rb | 6 + .../lib/splash/processors/splash_processor.rb | 53 ++++++++ new/splash/output/background.png | Bin 0 -> 3909 bytes new/splash/output/new.gif | Bin 0 -> 141 bytes new/splash/output/org.dillo.gif | Bin 0 -> 1899 bytes new/splash/output/org.freebsd.gif | Bin 0 -> 999 bytes new/splash/pages/.dir-locals.el | 7 +- new/splash/pages/background.png | 1 + new/splash/pages/index.html.erb | 145 ++++++++++++++++++++- 14 files changed, 217 insertions(+), 7 deletions(-) create mode 100644 new/splash/assets/images/background.png create mode 100644 new/splash/assets/images/buttons/org.dillo.gif create mode 100644 new/splash/assets/images/buttons/org.freebsd.gif create mode 100644 new/splash/assets/images/new.gif create mode 100644 new/splash/lib/splash/processors/splash_processor.rb create mode 100644 new/splash/output/background.png create mode 100644 new/splash/output/new.gif create mode 100644 new/splash/output/org.dillo.gif create mode 100644 new/splash/output/org.freebsd.gif create mode 100644 new/splash/pages/background.png (limited to 'new/splash') diff --git a/new/splash/assets/images/background.png b/new/splash/assets/images/background.png new file mode 100644 index 0000000..11f85e6 Binary files /dev/null and b/new/splash/assets/images/background.png differ diff --git a/new/splash/assets/images/buttons/org.dillo.gif b/new/splash/assets/images/buttons/org.dillo.gif new file mode 100644 index 0000000..850d4df Binary files /dev/null and b/new/splash/assets/images/buttons/org.dillo.gif differ diff --git a/new/splash/assets/images/buttons/org.freebsd.gif b/new/splash/assets/images/buttons/org.freebsd.gif new file mode 100644 index 0000000..cd41141 Binary files /dev/null and b/new/splash/assets/images/buttons/org.freebsd.gif differ diff --git a/new/splash/assets/images/new.gif b/new/splash/assets/images/new.gif new file mode 100644 index 0000000..b06fb07 Binary files /dev/null and b/new/splash/assets/images/new.gif differ diff --git a/new/splash/bin/build.rb b/new/splash/bin/build.rb index 404431f..1439dd6 100755 --- a/new/splash/bin/build.rb +++ b/new/splash/bin/build.rb @@ -6,6 +6,14 @@ require_relative '../../bin/builder' builder_class = Crys::Splash::Builder output_dir = "#{File.dirname(File.dirname(__FILE__))}/output" -file_path = "#{File.dirname(File.dirname(__FILE__))}/pages/#{@options[:filepath]}" +#file_path = "#{File.dirname(File.dirname(__FILE__))}/pages/#{@options[:filepath]}" +image_dir = "#{File.dirname(File.dirname(File.expand_path(__FILE__)))}/assets/images" -Crys::BuilderRunner.new(file_path: file_path, output_dir: output_dir, builder_class: builder_class).run +file_path=@options[:filepath] + +Crys::BuilderRunner.new( + file_path: file_path, + output_dir: output_dir, + builder_class: builder_class, + image_dir: image_dir +).run diff --git a/new/splash/lib/splash/builder.rb b/new/splash/lib/splash/builder.rb index 5a737e9..7b0f13f 100644 --- a/new/splash/lib/splash/builder.rb +++ b/new/splash/lib/splash/builder.rb @@ -1,8 +1,14 @@ # frozen_string_literal: true +require_relative "processors/splash_processor" + module Crys module Splash class Builder < Crys::Builder + + def html_processor + Crys::Splash::SplashProcessor + end end end end diff --git a/new/splash/lib/splash/processors/splash_processor.rb b/new/splash/lib/splash/processors/splash_processor.rb new file mode 100644 index 0000000..463dd65 --- /dev/null +++ b/new/splash/lib/splash/processors/splash_processor.rb @@ -0,0 +1,53 @@ +require "yaml" + +module Crys + module Splash + class SplashProcessor < Crys::HtmlProcessor + def not_real + [ + "doctor", + "starfleet officer", + "magician", + "hacker", + "emperor of an evil galaxy", + "replicant", + "computer", + "evil genius" + ].sample + end + + def update_badge(url_part) + @main_rss = fetch_rss(name: :main) + if @main_rss.items.last(20).any? { |it| it.link.include? url_part } + new_badge + end + end + + def more_update_badge(name:) + path = case name + when :bookmarks + "/assets/more/bookmarks.yml" + when :links + "/assets/more/links.yml" + end + + yaml = YAML.load_file(project_root + path) + _, vals = yaml.first + last_added = Time.parse(vals.last.fetch("date")) + + if (Time.now - last_added) / (24 * 60* 60) < 30 + new_badge + end + end + + + def new_badge + image = process_image(file: "new.gif") + code = ERB.new <<-EOF +NEW +EOF + code.result(binding) + end + end + end +end diff --git a/new/splash/output/background.png b/new/splash/output/background.png new file mode 100644 index 0000000..11f85e6 Binary files /dev/null and b/new/splash/output/background.png differ diff --git a/new/splash/output/new.gif b/new/splash/output/new.gif new file mode 100644 index 0000000..b06fb07 Binary files /dev/null and b/new/splash/output/new.gif differ diff --git a/new/splash/output/org.dillo.gif b/new/splash/output/org.dillo.gif new file mode 100644 index 0000000..850d4df Binary files /dev/null and b/new/splash/output/org.dillo.gif differ diff --git a/new/splash/output/org.freebsd.gif b/new/splash/output/org.freebsd.gif new file mode 100644 index 0000000..cd41141 Binary files /dev/null and b/new/splash/output/org.freebsd.gif differ diff --git a/new/splash/pages/.dir-locals.el b/new/splash/pages/.dir-locals.el index 4e2be03..22b2f46 100644 --- a/new/splash/pages/.dir-locals.el +++ b/new/splash/pages/.dir-locals.el @@ -1 +1,6 @@ -((nil . ((add-hook 'after-save-hook ('message :a)))) + +((nil + . ((eval . + (add-hook 'after-save-hook (lambda () (message (shell-command-to-string (format "../bin/build.rb -f%s" (buffer-file-name)))))) + )))) + diff --git a/new/splash/pages/background.png b/new/splash/pages/background.png new file mode 100644 index 0000000..22d26b7 --- /dev/null +++ b/new/splash/pages/background.png @@ -0,0 +1 @@ +# \ No newline at end of file diff --git a/new/splash/pages/index.html.erb b/new/splash/pages/index.html.erb index d033c90..e5ee6f6 100644 --- a/new/splash/pages/index.html.erb +++ b/new/splash/pages/index.html.erb @@ -1,9 +1,146 @@ - + + - It works! + + + Crys SITE + + + + + + + + + + + + -

Test

- Last update: <%= Time.now %> + +

Crys SITE

+ +

+ Hi! + I'm Michal and this is my personal webpage. +

+ +

+ The World Wide Web used to be fun, scrappy, and ours; let's bring it back. +

+ +

+ NOTE: I am not a real <%= not_real %>, and I can be wrong sometimes. + +

+ + +
+

+ Updated <%= Time.now.strftime("%B %d, %Y") %> +

+ +
+

Contents

+ +

Main sections

+ + + +
+ + +

Recent updates

+ + + + +
+

+ This is self-hosted site. + You are connected live to my living room. +

+ +
+ <%= webbutton(file: "org.freebsd.gif", url: "https://www.freebsd.org/", alt: "Powered by FreeBSD") %> + <%= webbutton(file: "org.dillo.gif", url: "https://www.dillo.org/", alt: "Optimized for Dillo") %> +
-- cgit v1.2.3