Version assets
This commit is contained in:
@@ -288,9 +288,9 @@ GEM
|
||||
net-ssh (7.1.0)
|
||||
netrc (0.11.0)
|
||||
nio4r (2.5.9)
|
||||
nokogiri (1.14.3-x86_64-darwin)
|
||||
nokogiri (1.14.4-x86_64-darwin)
|
||||
racc (~> 1.4)
|
||||
nokogiri (1.14.3-x86_64-linux)
|
||||
nokogiri (1.14.4-x86_64-linux)
|
||||
racc (~> 1.4)
|
||||
notiffany (0.1.3)
|
||||
nenv (~> 0.1)
|
||||
@@ -422,7 +422,7 @@ GEM
|
||||
standardrb (1.0.1)
|
||||
standard
|
||||
temple (0.10.0)
|
||||
thor (1.2.1)
|
||||
thor (1.2.2)
|
||||
tilt (2.1.0)
|
||||
time_math2 (0.1.1)
|
||||
timecop (0.9.6)
|
||||
|
@@ -21,12 +21,12 @@ html
|
||||
link rel="me" href=Hanami.app.settings.mastodon_url
|
||||
link rel="me" href=Hanami.app.settings.github_url
|
||||
|
||||
link rel="stylesheet" href="/assets/index.css"
|
||||
link rel="stylesheet" href=asset_from_manifest("index.css")
|
||||
link rel="icon" type="image/x-icon" href="/assets/favicon.ico"
|
||||
|
||||
script data-domain="dnitza.com" src="https://stats.dnitza.com/js/script.js" defer="true"
|
||||
script src="/assets/gallery.js"
|
||||
script src="/assets/index.js"
|
||||
script src=asset_from_manifest("index.js")
|
||||
|
||||
script src="https://unpkg.com/htmx.org@1.8.4" integrity="sha384-wg5Y/JwF7VxGk4zLsJEcAojRtlVp1FKKdGy1qN+OMtdq72WRvX/EdRdqg/LOhYeV" crossorigin="anonymous"
|
||||
script src="https://cdn.jsdelivr.net/npm/alpinejs@3.12.0/dist/cdn.min.js" defer="true"
|
||||
|
@@ -5,10 +5,22 @@ module Adamantium
|
||||
super(**options)
|
||||
end
|
||||
|
||||
def asset_from_manifest(filename)
|
||||
return "/assets/#{filename}" if Hanami.env != :production
|
||||
hashed_filename = asset_manifest[filename]
|
||||
"/assets/dist/#{hashed_filename}"
|
||||
end
|
||||
|
||||
def link_active? path
|
||||
# TODO: waiting for Hanami View to be released
|
||||
# to access current_path
|
||||
false
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def asset_manifest
|
||||
@asset_manifest ||= JSON.parse(File.read("public/assets/asset-manifest.json"))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
1
public/assets/asset-manifest.json
Normal file
1
public/assets/asset-manifest.json
Normal file
@@ -0,0 +1 @@
|
||||
{"gallery.js":"gallery-SO2jW2qeQ-oB.js","index.js":"index-SO2jW2qeQ-oB.js","index.css":"index-SO2jW2qeQ-oB.css"}
|
103
public/assets/dist/gallery-SO2jW2qeQ-oB.js
vendored
Normal file
103
public/assets/dist/gallery-SO2jW2qeQ-oB.js
vendored
Normal file
@@ -0,0 +1,103 @@
|
||||
/*
|
||||
Markdown Gallery
|
||||
-- v1.0 2016
|
||||
-- Created by Lee Penney
|
||||
-- Released under GPLv3
|
||||
*/
|
||||
|
||||
function md_gallery(config) {
|
||||
var config = config || {},
|
||||
list_type = config.list_type || 'ul',
|
||||
class_name = config.class_name || 'gallery',
|
||||
tag_type = config.tag_type || 'div';
|
||||
|
||||
function find_lists(list_type) {
|
||||
var lists = document.getElementsByTagName(list_type), matching_lists = [];
|
||||
for (var i = 0; i < lists.length; i++) {
|
||||
var list_elements = lists[i].children;
|
||||
var total_matches = 0;
|
||||
for (var c = 0; c < list_elements.length; c++) {
|
||||
if (!list_elements[c].textContent.length && (list_elements[c].firstChild.tagName == 'A' || list_elements[c].firstChild.tagName == 'IMG') && (!list_elements[c].firstChild.firstChild || (list_elements[c].firstChild.firstChild && list_elements[c].firstChild.firstChild.tagName == 'IMG') )) {
|
||||
total_matches++;
|
||||
}
|
||||
}
|
||||
if (total_matches == list_elements.length) {
|
||||
matching_lists[matching_lists.length] = lists[i];
|
||||
}
|
||||
}
|
||||
return matching_lists;
|
||||
}
|
||||
|
||||
function prepend_tag(img_lists, list_tag, prepend_tag, class_name) {
|
||||
for (var i = 0; i < img_lists.length; i++) {
|
||||
// add_figure_tags(img_lists[i]);
|
||||
add_anchor(img_lists[i]);
|
||||
wrap_tag(img_lists[i], prepend_tag, class_name, null, true);
|
||||
strip_tag(img_lists[i], 'li');
|
||||
strip_tag(img_lists[i].parentNode, list_tag);
|
||||
}
|
||||
}
|
||||
|
||||
function append_caption(el) {
|
||||
if ((el.tagName == 'A' && el.firstChild.tagName == 'IMG' && el.firstChild.hasAttribute('alt') && el.firstChild.getAttribute('alt').length > 0) || (el.tagName == 'IMG' && el.hasAttribute('alt') && el.getAttribute('alt').length > 0)) {
|
||||
var caption = document.createElement('figcaption');
|
||||
try {
|
||||
caption.textContent = el.firstChild.getAttribute('alt')
|
||||
el.appendChild(caption);
|
||||
} catch (e) {
|
||||
caption.textContent = el.getAttribute('alt');
|
||||
el.parentNode.appendChild(caption);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function strip_tag(el, tag_type) {
|
||||
var start_tag_regex = new RegExp('<'+tag_type+'>', 'gi');
|
||||
var end_tag_regex = new RegExp('<\/'+tag_type+'>', 'gi');
|
||||
el.innerHTML = el.innerHTML.replace(start_tag_regex,'').replace(end_tag_regex,'');
|
||||
}
|
||||
|
||||
function add_figure_tags(img_list) {
|
||||
var list_elements = img_list.children;
|
||||
for (var i = 0; i < list_elements.length; i++) {
|
||||
append_caption(list_elements[i].firstChild);
|
||||
wrap_tag(list_elements[i], 'figure');
|
||||
}
|
||||
}
|
||||
|
||||
function add_anchor(img_list) {
|
||||
var list_elements = img_list.children;
|
||||
for (var i = 0; i < list_elements.length; i++) {
|
||||
let img = list_elements[i].getElementsByTagName('img')[0];
|
||||
let src = img.getAttribute("src");
|
||||
let alt = img.getAttribute("alt");
|
||||
wrap_tag(list_elements[i],
|
||||
'a',
|
||||
'hover:cursor-pointer',
|
||||
"$dispatch('img-modal', { imgModalSrc: '" + src + "', imgModalDesc: '" + alt + "' })",
|
||||
false
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
function wrap_tag(el, tag_type, class_name, click, root) {
|
||||
var wrap = document.createElement(tag_type);
|
||||
if (root) {
|
||||
wrap.setAttribute('x-data', "{}");
|
||||
}
|
||||
if (class_name) {
|
||||
wrap.setAttribute('class', class_name);
|
||||
}
|
||||
if (click) {
|
||||
wrap.setAttribute('x-on:click.prevent', click);
|
||||
wrap.setAttribute('href', '#');
|
||||
}
|
||||
el.parentNode.replaceChild(wrap, el);
|
||||
wrap.appendChild(el);
|
||||
}
|
||||
|
||||
var found_img_lists = find_lists(list_type);
|
||||
if (found_img_lists.length) {
|
||||
prepend_tag(found_img_lists, list_type, tag_type, class_name);
|
||||
}
|
||||
}
|
2225
public/assets/dist/index-SO2jW2qeQ-oB.css
vendored
Normal file
2225
public/assets/dist/index-SO2jW2qeQ-oB.css
vendored
Normal file
File diff suppressed because it is too large
Load Diff
31
public/assets/dist/index-SO2jW2qeQ-oB.js
vendored
Normal file
31
public/assets/dist/index-SO2jW2qeQ-oB.js
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
(function() {
|
||||
document.addEventListener('alpine:init', () => {
|
||||
Alpine.magic('clipboard', () => {
|
||||
return subject => navigator.clipboard.writeText(subject)
|
||||
})
|
||||
})
|
||||
document.addEventListener("DOMContentLoaded", function () {
|
||||
const times = document.querySelectorAll('time');
|
||||
times.forEach((time) => {
|
||||
const oldDtime = Date.parse(time.dateTime);
|
||||
time.innerHTML = new Date(oldDtime).toLocaleDateString(navigator.language, { weekday:"long", year:"numeric", month:"short", day:"numeric"});
|
||||
|
||||
md_gallery({
|
||||
"class_name": "grid gap-4 grid-cols-2 prose-img:m-0"
|
||||
});
|
||||
});
|
||||
// mapboxgl.accessToken = 'pk.eyJ1IjoiZG5pdHphIiwiYSI6ImNsZWIyY3ZzaTE0cjUzdm4xdnZ6czRlYjUifQ.FRETOXYRID6T2IoB7qqRLg';
|
||||
// var map = new mapboxgl.Map({
|
||||
// container: 'map',
|
||||
// style: 'mapbox://styles/mapbox/streets-v11'
|
||||
// });
|
||||
// const mapContainer = document.getElementById("map");
|
||||
// const markers = JSON.parse(mapContainer.dataset["markers"]);
|
||||
// for (var i = 0; i < markers.length; i++) {
|
||||
// const marker = markers[i];
|
||||
// new mapboxgl.Marker()
|
||||
// .setLngLat(marker)
|
||||
// .addTo(map);
|
||||
// }
|
||||
});
|
||||
})();
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
! tailwindcss v3.3.0 | MIT License | https://tailwindcss.com
|
||||
! tailwindcss v3.3.2 | MIT License | https://tailwindcss.com
|
||||
*/
|
||||
|
||||
/*
|
||||
@@ -436,6 +436,9 @@ video {
|
||||
--tw-pan-y: ;
|
||||
--tw-pinch-zoom: ;
|
||||
--tw-scroll-snap-strictness: proximity;
|
||||
--tw-gradient-from-position: ;
|
||||
--tw-gradient-via-position: ;
|
||||
--tw-gradient-to-position: ;
|
||||
--tw-ordinal: ;
|
||||
--tw-slashed-zero: ;
|
||||
--tw-numeric-figure: ;
|
||||
@@ -483,6 +486,9 @@ video {
|
||||
--tw-pan-y: ;
|
||||
--tw-pinch-zoom: ;
|
||||
--tw-scroll-snap-strictness: proximity;
|
||||
--tw-gradient-from-position: ;
|
||||
--tw-gradient-via-position: ;
|
||||
--tw-gradient-to-position: ;
|
||||
--tw-ordinal: ;
|
||||
--tw-slashed-zero: ;
|
||||
--tw-numeric-figure: ;
|
||||
@@ -2072,6 +2078,11 @@ h1, h2, h3, h4, h5, h6, h1 a, h2 a, h3 a, h4 a, h5 a, h6 a {
|
||||
background-color: rgb(250 204 21 / var(--tw-bg-opacity));
|
||||
}
|
||||
|
||||
.dark\:bg-green-800 {
|
||||
--tw-bg-opacity: 1;
|
||||
background-color: rgb(22 101 52 / var(--tw-bg-opacity));
|
||||
}
|
||||
|
||||
.dark\:text-blue-200 {
|
||||
--tw-text-opacity: 1;
|
||||
color: rgb(191 219 254 / var(--tw-text-opacity));
|
||||
|
@@ -8,10 +8,10 @@ html
|
||||
|
||||
title Admin // Daniel Nitsikopoulos
|
||||
|
||||
link rel="stylesheet" href="/assets/index.css"
|
||||
link rel="stylesheet" href=asset_from_manifest("index.css")
|
||||
link rel="icon" type="image/x-icon" href="/assets/favicon.ico"
|
||||
|
||||
script src="/assets/index.js"
|
||||
script src=asset_from_manifest("index.js")
|
||||
|
||||
script src="https://unpkg.com/htmx.org@1.9.2" integrity="sha384-L6OqL9pRWyyFU3+/bjdSri+iIphTN/bvYyM37tICVyOJkWZLpP2vGn6VUEXgzg6h" crossorigin="anonymous"
|
||||
script src="https://cdn.jsdelivr.net/npm/alpinejs@3.12.0/dist/cdn.min.js" defer="true"
|
||||
|
27
version_assets.rb
Normal file
27
version_assets.rb
Normal file
@@ -0,0 +1,27 @@
|
||||
# get index.css, index.js
|
||||
# generate hash
|
||||
# rename files
|
||||
# write asset manifest
|
||||
|
||||
require "securerandom"
|
||||
require "json"
|
||||
require "fileutils"
|
||||
|
||||
folder_path = File.join(__dir__, "/public/assets")
|
||||
dist_path = File.join(__dir__, "/public/assets/dist")
|
||||
hash = SecureRandom.urlsafe_base64(9)
|
||||
filenames = {}
|
||||
|
||||
FileUtils.rm_rf("#{dist_path}/.", secure: true)
|
||||
|
||||
Dir.glob(folder_path + "/*.{js,css}").each do |f|
|
||||
FileUtils.cp(f, dist_path)
|
||||
end
|
||||
|
||||
Dir.glob(dist_path + "/*.{js,css}").each_with_object(filenames) do |f, memo|
|
||||
filename = File.basename(f, File.extname(f))
|
||||
memo[filename + File.extname(f)] = filename + "-" + hash + File.extname(f)
|
||||
File.rename(f, dist_path + "/" + filename + "-" + hash + File.extname(f))
|
||||
end
|
||||
|
||||
File.open(folder_path + "/asset-manifest.json", "wb") {|f| f.write(JSON.generate(filenames)) }
|
Reference in New Issue
Block a user