From d76d69d4df940b542328accb91035f2db3833648 Mon Sep 17 00:00:00 2001 From: lwcarani Date: Thu, 4 Apr 2024 22:00:22 -0400 Subject: [PATCH] revert to base files from starter --- _includes/.DS_Store | Bin 6148 -> 0 bytes _includes/comments.html | 5 - _includes/comments/disqus.html | 50 -- _includes/comments/giscus.html | 65 --- _includes/comments/utterances.html | 50 -- _includes/datetime.html | 20 - _includes/embed/bilibili.html | 10 - _includes/embed/twitch.html | 8 - _includes/embed/youtube.html | 9 - _includes/favicons.html | 19 - _includes/footer.html | 42 -- _includes/google-analytics.html | 14 - _includes/head.html | 120 ---- _includes/img-url.html | 39 -- _includes/js-selector.html | 108 ---- _includes/jsdelivr-combine.html | 26 - _includes/lang.html | 8 - _includes/language-alias.html | 70 --- _includes/mermaid.html | 58 -- _includes/metadata-hook.html | 1 - _includes/mode-toggle.html | 143 ----- _includes/no-linenos.html | 10 - _includes/notification.html | 24 - _includes/origin-type.html | 13 - _includes/post-nav.html | 34 -- _includes/post-paginator.html | 91 --- _includes/post-sharing.html | 52 -- _includes/read-time.html | 37 -- _includes/refactor-content.html | 255 -------- _includes/related-posts.html | 96 ---- _includes/rent_vs_buy_blog_post.md | 544 ------------------ _includes/search-loader.html | 47 -- _includes/search-results.html | 10 - _includes/sidebar.html | 99 ---- _includes/toc.html | 13 - _includes/topbar.html | 77 --- _includes/trending-tags.html | 46 -- _includes/update-list.html | 40 -- _javascript/.DS_Store | Bin 6148 -> 0 bytes _javascript/_copyright | 1 - _javascript/categories.js | 7 - _javascript/commons.js | 5 - _javascript/home.js | 8 - _javascript/misc.js | 7 - _javascript/modules/.DS_Store | Bin 6148 -> 0 bytes _javascript/modules/components/back-to-top.js | 20 - .../modules/components/category-collapse.js | 36 -- _javascript/modules/components/clipboard.js | 130 ----- _javascript/modules/components/img-loading.js | 61 -- _javascript/modules/components/img-popup.js | 22 - .../modules/components/locale-datetime.js | 51 -- .../modules/components/mode-watcher.js | 21 - .../modules/components/search-display.js | 122 ---- _javascript/modules/components/sidebar.js | 25 - _javascript/modules/components/toc.js | 13 - .../modules/components/tooltip-loader.js | 12 - _javascript/modules/layouts.js | 3 - _javascript/modules/layouts/basic.js | 7 - _javascript/modules/layouts/sidebar.js | 7 - _javascript/modules/layouts/topbar.js | 5 - _javascript/modules/plugins.js | 6 - _javascript/page.js | 9 - _javascript/post.js | 17 - _javascript/pwa/app.js | 58 -- _javascript/pwa/sw.js | 101 ---- assets/js/.DS_Store | Bin 6148 -> 0 bytes assets/js/data/search.json | 20 - assets/js/data/swconf.js | 51 -- 68 files changed, 3178 deletions(-) delete mode 100644 _includes/.DS_Store delete mode 100644 _includes/comments.html delete mode 100644 _includes/comments/disqus.html delete mode 100644 _includes/comments/giscus.html delete mode 100644 _includes/comments/utterances.html delete mode 100644 _includes/datetime.html delete mode 100644 _includes/embed/bilibili.html delete mode 100644 _includes/embed/twitch.html delete mode 100644 _includes/embed/youtube.html delete mode 100644 _includes/favicons.html delete mode 100644 _includes/footer.html delete mode 100644 _includes/google-analytics.html delete mode 100644 _includes/head.html delete mode 100644 _includes/img-url.html delete mode 100644 _includes/js-selector.html delete mode 100644 _includes/jsdelivr-combine.html delete mode 100644 _includes/lang.html delete mode 100644 _includes/language-alias.html delete mode 100644 _includes/mermaid.html delete mode 100644 _includes/metadata-hook.html delete mode 100644 _includes/mode-toggle.html delete mode 100644 _includes/no-linenos.html delete mode 100644 _includes/notification.html delete mode 100644 _includes/origin-type.html delete mode 100644 _includes/post-nav.html delete mode 100644 _includes/post-paginator.html delete mode 100644 _includes/post-sharing.html delete mode 100644 _includes/read-time.html delete mode 100644 _includes/refactor-content.html delete mode 100644 _includes/related-posts.html delete mode 100644 _includes/rent_vs_buy_blog_post.md delete mode 100644 _includes/search-loader.html delete mode 100644 _includes/search-results.html delete mode 100644 _includes/sidebar.html delete mode 100644 _includes/toc.html delete mode 100644 _includes/topbar.html delete mode 100644 _includes/trending-tags.html delete mode 100644 _includes/update-list.html delete mode 100644 _javascript/.DS_Store delete mode 100644 _javascript/_copyright delete mode 100644 _javascript/categories.js delete mode 100644 _javascript/commons.js delete mode 100644 _javascript/home.js delete mode 100644 _javascript/misc.js delete mode 100644 _javascript/modules/.DS_Store delete mode 100644 _javascript/modules/components/back-to-top.js delete mode 100644 _javascript/modules/components/category-collapse.js delete mode 100644 _javascript/modules/components/clipboard.js delete mode 100644 _javascript/modules/components/img-loading.js delete mode 100644 _javascript/modules/components/img-popup.js delete mode 100644 _javascript/modules/components/locale-datetime.js delete mode 100644 _javascript/modules/components/mode-watcher.js delete mode 100644 _javascript/modules/components/search-display.js delete mode 100644 _javascript/modules/components/sidebar.js delete mode 100644 _javascript/modules/components/toc.js delete mode 100644 _javascript/modules/components/tooltip-loader.js delete mode 100644 _javascript/modules/layouts.js delete mode 100644 _javascript/modules/layouts/basic.js delete mode 100644 _javascript/modules/layouts/sidebar.js delete mode 100644 _javascript/modules/layouts/topbar.js delete mode 100644 _javascript/modules/plugins.js delete mode 100644 _javascript/page.js delete mode 100644 _javascript/post.js delete mode 100644 _javascript/pwa/app.js delete mode 100644 _javascript/pwa/sw.js delete mode 100644 assets/js/.DS_Store delete mode 100644 assets/js/data/search.json delete mode 100644 assets/js/data/swconf.js diff --git a/_includes/.DS_Store b/_includes/.DS_Store deleted file mode 100644 index 4b1a5ccfdec2f2ddce77b2770d3392cf214cd7b1..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 6148 zcmeHKu};G<5IvU^MIc0xKw<$!>>&CFp$cEng$+m>QJ^7}3IkidpyD$aVM1bt4e7Az2tmnzdR{+Ohl@6(QOhnh{#7{^yc6yjQhEjtY#xztn?U{ z)W@|+9Xc#!OF$G51*S~_{&p8=i%uw^Q*yuG4)rMMA2r*ZEFBoyv&rP_G>f9RpT)@X zQ_uTYe|p^csiOPKib2n16kvF&(>@L9n9hrQ)#!Dx*z59Jx?LF!pEW}Gq4yIRa@Su%5k}@-M?J#-DxhRv0O%z@?2g-+svyDJ}JfU-6Esf zd$HH$^6)n1;?%n=sxvC)XAWZ1s{r(J(?^DhP01QtV!xk2>6lqm(8Qe}@A%9JA>*u2nUZqSsI(lcWmJF~JU6s2cJJkaT+ zLWAN(0a2i+z>Ilp@czI1{rSIGBu}D%DDbZoP+ruIT6iV9x0YUx_u2sM0F90Fa)Y`A j&Thy0hPUEXG;Qb$_y!nS%nc#}lOF*sgE&#(PZjtCF>{sj diff --git a/_includes/comments.html b/_includes/comments.html deleted file mode 100644 index 39e521f..0000000 --- a/_includes/comments.html +++ /dev/null @@ -1,5 +0,0 @@ - -{% if page.comments and site.comments.active %} - {% capture path %}comments/{{ site.comments.active }}.html{% endcapture %} - {% include {{ path }} %} -{% endif %} diff --git a/_includes/comments/disqus.html b/_includes/comments/disqus.html deleted file mode 100644 index e59ed37..0000000 --- a/_includes/comments/disqus.html +++ /dev/null @@ -1,50 +0,0 @@ - - -
-

Comments powered by Disqus.

-
- - diff --git a/_includes/comments/giscus.html b/_includes/comments/giscus.html deleted file mode 100644 index 8f04246..0000000 --- a/_includes/comments/giscus.html +++ /dev/null @@ -1,65 +0,0 @@ - - diff --git a/_includes/comments/utterances.html b/_includes/comments/utterances.html deleted file mode 100644 index 34dddcd..0000000 --- a/_includes/comments/utterances.html +++ /dev/null @@ -1,50 +0,0 @@ - - - - diff --git a/_includes/datetime.html b/_includes/datetime.html deleted file mode 100644 index 9f954b6..0000000 --- a/_includes/datetime.html +++ /dev/null @@ -1,20 +0,0 @@ - - -{% assign df_strftime = site.data.locales[include.lang].df.post.strftime | default: '%d/%m/%Y' %} -{% assign df_dayjs = site.data.locales[include.lang].df.post.dayjs | default: 'DD/MM/YYYY' %} - - diff --git a/_includes/embed/bilibili.html b/_includes/embed/bilibili.html deleted file mode 100644 index eaa09d8..0000000 --- a/_includes/embed/bilibili.html +++ /dev/null @@ -1,10 +0,0 @@ - \ No newline at end of file diff --git a/_includes/embed/twitch.html b/_includes/embed/twitch.html deleted file mode 100644 index ed5ec83..0000000 --- a/_includes/embed/twitch.html +++ /dev/null @@ -1,8 +0,0 @@ - diff --git a/_includes/embed/youtube.html b/_includes/embed/youtube.html deleted file mode 100644 index 640011f..0000000 --- a/_includes/embed/youtube.html +++ /dev/null @@ -1,9 +0,0 @@ - diff --git a/_includes/favicons.html b/_includes/favicons.html deleted file mode 100644 index 957c933..0000000 --- a/_includes/favicons.html +++ /dev/null @@ -1,19 +0,0 @@ - - -{% capture favicon_path %}{{ '/assets/img/favicons' | relative_url }}{% endcapture %} - - - - -{% if site.pwa.enabled %} - -{% endif %} - - - - - - diff --git a/_includes/footer.html b/_includes/footer.html deleted file mode 100644 index a015f46..0000000 --- a/_includes/footer.html +++ /dev/null @@ -1,42 +0,0 @@ - - -
-

- {{- '©' }} - - - {% if site.social.links %} - {{ site.social.name }}. - {% else %} - {{ site.social.name }}. - {% endif %} - - {% if site.data.locales[include.lang].copyright.brief %} - - {{- site.data.locales[include.lang].copyright.brief -}} - - {% endif %} -

- -

- {%- capture _platform -%} - Jekyll - {%- endcapture -%} - - {%- capture _theme -%} - Chirpy - {%- endcapture -%} - - {{ site.data.locales[include.lang].meta | replace: ':PLATFORM', _platform | replace: ':THEME', _theme }} -

-
diff --git a/_includes/google-analytics.html b/_includes/google-analytics.html deleted file mode 100644 index e5e5119..0000000 --- a/_includes/google-analytics.html +++ /dev/null @@ -1,14 +0,0 @@ - - - - diff --git a/_includes/head.html b/_includes/head.html deleted file mode 100644 index 839af65..0000000 --- a/_includes/head.html +++ /dev/null @@ -1,120 +0,0 @@ - - - - - - - - - {%- capture seo_tags -%} - {% seo title=false %} - {%- endcapture -%} - - - - {% if page.image %} - {% assign src = page.image.path | default: page.image %} - - {% unless src contains '://' %} - {%- capture img_url -%} - {% include img-url.html src=src img_path=page.img_path absolute=true %} - {%- endcapture -%} - - {%- capture old_url -%}{{ src | absolute_url }}{%- endcapture -%} - {%- capture new_url -%}{{ img_url }}{%- endcapture -%} - - {% assign seo_tags = seo_tags | replace: old_url, new_url %} - {% endunless %} - - {% elsif site.social_preview_image %} - {%- capture img_url -%} - {% include img-url.html src=site.social_preview_image absolute=true %} - {%- endcapture -%} - - {%- capture og_image -%} - - {%- endcapture -%} - - {%- capture twitter_image -%} - - - {%- endcapture -%} - - {% assign old_meta_clip = '' %} - {% assign new_meta_clip = og_image | append: twitter_image %} - {% assign seo_tags = seo_tags | replace: old_meta_clip, new_meta_clip %} - {% endif %} - - {{ seo_tags }} - - - - - - {%- unless page.layout == 'home' -%} - {{ page.title | append: ' | ' }} - {%- endunless -%} - {{ site.title }} - - - {% include_cached favicons.html %} - - {% if site.resources.ignore_env != jekyll.environment and site.resources.self_hosted %} - - - {% else %} - {% for cdn in site.data.origin[type].cdns %} - - - {% endfor %} - - - {% endif %} - - - {% if jekyll.environment == 'production' and site.google_analytics.id != empty and site.google_analytics.id %} - - - - - - {% endif %} - - - - - - - - - - {% if site.toc and page.toc %} - - {% endif %} - - {% if page.layout == 'post' or page.layout == 'page' or page.layout == 'home' %} - - {% endif %} - - {% if page.layout == 'page' or page.layout == 'post' %} - - - {% endif %} - - - - {% unless site.theme_mode %} - {% include mode-toggle.html %} - {% endunless %} - - {% include metadata-hook.html %} - diff --git a/_includes/img-url.html b/_includes/img-url.html deleted file mode 100644 index c08e8b9..0000000 --- a/_includes/img-url.html +++ /dev/null @@ -1,39 +0,0 @@ -{%- comment -%} - Generate image final URL based on `site.img_cdn`, `page.img_path` - - Arguments: - src - required, basic image path - img_path - optional, relative path of image - absolute - optional, boolean, if true, generate absolute URL - - Return: - image URL -{%- endcomment -%} - -{% assign url = include.src %} - -{%- if url -%} - {% unless url contains ':' %} - {%- comment -%} CND URL {%- endcomment -%} - {% assign prefix = site.img_cdn | default: '' %} - - {%- comment -%} Add page image path prefix {%- endcomment -%} - {% assign url = include.img_path | default: '' | append: '/' | append: url %} - - {% assign url = prefix - | append: '/' - | append: url - | replace: '///', '/' - | replace: '//', '/' - | replace: ':', ':/' - %} - - {% if include.absolute %} - {% assign url = url | absolute_url %} - {% else %} - {% assign url = url | relative_url %} - {% endif %} - {% endunless %} -{%- endif -%} - -{{- url -}} diff --git a/_includes/js-selector.html b/_includes/js-selector.html deleted file mode 100644 index 0e7f6f4..0000000 --- a/_includes/js-selector.html +++ /dev/null @@ -1,108 +0,0 @@ - - - - -{% assign urls = site.data.origin[type].jquery.js - | append: ',' - | append: site.data.origin[type].bootstrap.js - | append: ',' - | append: site.data.origin[type].search.js -%} - - - -{% assign js_dist = '/assets/js/dist/' %} - -{% if page.layout == 'post' or page.layout == 'page' or page.layout == 'home' %} - {% assign urls = urls | append: ',' | append: site.data.origin[type]['lazy-polyfill'].js %} - - {% unless page.layout == 'home' %} - - {% assign urls = urls - | append: ',' - | append: site.data.origin[type]['magnific-popup'].js - | append: ',' - | append: site.data.origin[type].clipboard.js - %} - {% endunless %} -{% endif %} - -{% if page.layout == 'home' - or page.layout == 'post' - or page.layout == 'archives' - or page.layout == 'category' - or page.layout == 'tag' -%} - {% assign locale = site.lang | split: '-' | first %} - - {% assign urls = urls - | append: ',' - | append: site.data.origin[type].dayjs.js.common - | append: ',' - | append: site.data.origin[type].dayjs.js.locale - | replace: ':LOCALE', locale - | append: ',' - | append: site.data.origin[type].dayjs.js.relativeTime - | append: ',' - | append: site.data.origin[type].dayjs.js.localizedFormat - %} -{% endif %} - -{% if page.content contains ' - -{% if page.math %} - - - - -{% endif %} - -{% if jekyll.environment == 'production' %} - - {% if site.pwa.enabled %} - - {% endif %} - - - {% if site.google_analytics.id != empty and site.google_analytics.id %} - {% include google-analytics.html %} - {% endif %} -{% endif %} diff --git a/_includes/jsdelivr-combine.html b/_includes/jsdelivr-combine.html deleted file mode 100644 index cffa699..0000000 --- a/_includes/jsdelivr-combine.html +++ /dev/null @@ -1,26 +0,0 @@ -{% assign urls = include.urls | split: ',' %} - -{% assign combined_urls = nil %} - -{% assign domain = 'https://cdn.jsdelivr.net/' %} - -{% for url in urls %} - {% if url contains domain %} - {% assign url_snippet = url | slice: domain.size, url.size %} - - {% if combined_urls %} - {% assign combined_urls = combined_urls | append: ',' | append: url_snippet %} - {% else %} - {% assign combined_urls = domain | append: 'combine/' | append: url_snippet %} - {% endif %} - - {% elsif url contains '//' %} - - {% else %} - - {% endif %} -{% endfor %} - -{% if combined_urls %} - -{% endif %} diff --git a/_includes/lang.html b/_includes/lang.html deleted file mode 100644 index 19558a0..0000000 --- a/_includes/lang.html +++ /dev/null @@ -1,8 +0,0 @@ -{% comment %} - Detect appearance language and return it through variable "lang" -{% endcomment %} -{% if site.data.locales[site.lang] %} - {% assign lang = site.lang %} -{% else %} - {% assign lang = 'en' %} -{% endif %} diff --git a/_includes/language-alias.html b/_includes/language-alias.html deleted file mode 100644 index abfa7ba..0000000 --- a/_includes/language-alias.html +++ /dev/null @@ -1,70 +0,0 @@ -{% comment %} - - Convert the alias of the syntax language to the official name - - See: - -{% endcomment %} - -{% assign _lang = include.language | default: '' %} - -{% case _lang %} - {% when 'actionscript', 'as', 'as3' %} - {{ 'ActionScript' }} - {% when 'applescript' %} - {{ 'AppleScript' }} - {% when 'brightscript', 'bs', 'brs' %} - {{ 'BrightScript' }} - {% when 'cfscript', 'cfc' %} - {{ 'CFScript' }} - {% when 'coffeescript', 'coffee', 'coffee-script' %} - {{ 'CoffeeScript' }} - {% when 'cs', 'csharp' %} - {{ 'C#' }} - {% when 'erl' %} - {{ 'Erlang' }} - {% when 'graphql' %} - {{ 'GraphQL' }} - {% when 'haskell', 'hs' %} - {{ 'Haskell' }} - {% when 'javascript', 'js' %} - {{ 'JavaScript' }} - {% when 'make', 'mf', 'gnumake', 'bsdmake' %} - {{ 'Makefile' }} - {% when 'md', 'mkd' %} - {{ 'Markdown' }} - {% when 'm' %} - {{ 'Matlab' }} - {% when 'objective_c', 'objc', 'obj-c', 'obj_c', 'objectivec' %} - {{ 'Objective-C' }} - {% when 'perl', 'pl' %} - {{ 'Perl' }} - {% when 'php','php3','php4','php5' %} - {{ 'PHP' }} - {% when 'py' %} - {{ 'Python' }} - {% when 'rb' %} - {{ 'Ruby' }} - {% when 'rs','no_run','ignore','should_panic' %} - {{ 'Rust' }} - {% when 'bash', 'zsh', 'ksh', 'sh' %} - {{ 'Shell' }} - {% when 'st', 'squeak' %} - {{ 'Smalltalk' }} - {% when 'tex'%} - {{ 'TeX' }} - {% when 'latex' %} - {{ 'LaTex' }} - {% when 'ts', 'typescript' %} - {{ 'TypeScript' }} - {% when 'vb', 'visualbasic' %} - {{ 'Visual Basic' }} - {% when 'vue', 'vuejs' %} - {{ 'Vue.js' }} - {% when 'yml' %} - {{ 'YAML' }} - {% when 'css', 'html', 'scss', 'ssh', 'toml', 'xml', 'yaml', 'json' %} - {{ _lang | upcase }} - {% else %} - {{ _lang | capitalize }} -{% endcase %} diff --git a/_includes/mermaid.html b/_includes/mermaid.html deleted file mode 100644 index 967cfb4..0000000 --- a/_includes/mermaid.html +++ /dev/null @@ -1,58 +0,0 @@ - - diff --git a/_includes/metadata-hook.html b/_includes/metadata-hook.html deleted file mode 100644 index fd7e9bd..0000000 --- a/_includes/metadata-hook.html +++ /dev/null @@ -1 +0,0 @@ - diff --git a/_includes/mode-toggle.html b/_includes/mode-toggle.html deleted file mode 100644 index a347750..0000000 --- a/_includes/mode-toggle.html +++ /dev/null @@ -1,143 +0,0 @@ - - - diff --git a/_includes/no-linenos.html b/_includes/no-linenos.html deleted file mode 100644 index 8500693..0000000 --- a/_includes/no-linenos.html +++ /dev/null @@ -1,10 +0,0 @@ -{% comment %} - Remove the line number of the code snippet. -{% endcomment %} - -{% assign content = include.content %} - -{% if content contains '
' %}
-  {% assign content = content | replace: '
', '' %}
-{% endif %}
diff --git a/_includes/notification.html b/_includes/notification.html
deleted file mode 100644
index 80049b0..0000000
--- a/_includes/notification.html
+++ /dev/null
@@ -1,24 +0,0 @@
-
diff --git a/_includes/origin-type.html b/_includes/origin-type.html
deleted file mode 100644
index 7f72012..0000000
--- a/_includes/origin-type.html
+++ /dev/null
@@ -1,13 +0,0 @@
-{% comment %} Site static assets origin type {% endcomment %}
-
-{% assign type = 'cors' %}
-
-{% if site.assets.self_host.enabled %}
-  {% if site.assets.self_host.env %}
-    {% if site.assets.self_host.env == jekyll.environment %}
-      {% assign type = 'basic' %}
-    {% endif %}
-  {% else %}
-    {% assign type = 'basic' %}
-  {% endif %}
-{% endif %}
diff --git a/_includes/post-nav.html b/_includes/post-nav.html
deleted file mode 100644
index 736bec3..0000000
--- a/_includes/post-nav.html
+++ /dev/null
@@ -1,34 +0,0 @@
-
-
-
diff --git a/_includes/post-paginator.html b/_includes/post-paginator.html
deleted file mode 100644
index c74e978..0000000
--- a/_includes/post-paginator.html
+++ /dev/null
@@ -1,91 +0,0 @@
-
-
-
-
diff --git a/_includes/post-sharing.html b/_includes/post-sharing.html
deleted file mode 100644
index d894199..0000000
--- a/_includes/post-sharing.html
+++ /dev/null
@@ -1,52 +0,0 @@
-
-
-
diff --git a/_includes/read-time.html b/_includes/read-time.html
deleted file mode 100644
index 9952410..0000000
--- a/_includes/read-time.html
+++ /dev/null
@@ -1,37 +0,0 @@
-
-
-{% assign words = include.content | strip_html | number_of_words: 'auto' %}
-
-
-
-{% assign wpm = 180 %}
-{% assign min_time = 1 %}
-
-{% assign read_time = words | divided_by: wpm %}
-
-{% unless read_time > 0 %}
-  {% assign read_time = min_time %}
-{% endunless %}
-
-{% capture read_prompt %}
-  {{- site.data.locales[include.lang].post.read_time.prompt -}}
-{% endcapture %}
-
-
-
-  
-    {{- read_time -}}
-    {{ ' ' }}
-    {{- site.data.locales[include.lang].post.read_time.unit -}}
-  
-  {%- if include.prompt -%}
-    {%- assign _prompt_words = read_prompt | number_of_words: 'auto' -%}
-    {%- unless _prompt_words > 1 -%}{{ ' ' }}{%- endunless -%}
-    {{ read_prompt }}
-  {%- endif -%}
-
diff --git a/_includes/refactor-content.html b/_includes/refactor-content.html
deleted file mode 100644
index e4abcbc..0000000
--- a/_includes/refactor-content.html
+++ /dev/null
@@ -1,255 +0,0 @@
-
-
-{% assign _content = include.content %}
-
-
-
-{% if _content contains '', ''
-    | replace: '
', '' - | replace: '
', '
' - %} -{% endif %} - - - -{% if _content contains '
' %}
-  {% assign _content = _content
-    | replace: '
', '' - %} -{% endif %} - - - -{% if _content contains '', - '' - | replace: '', - '' - %} -{% endif %} - - - -{% assign IMG_TAG = '' | first %} - {% assign _right = _img_snippet | remove: _left %} - - {% unless _left contains 'src=' %} - {% continue %} - {% endunless %} - - {% assign _left = _left | remove: ' /' | replace: ' w=', ' width=' | replace: ' h=', ' height=' %} - {% assign _attrs = _left | split: '" ' %} - - {% assign _src = null %} - {% assign _lqip = null %} - {% assign _class = null %} - - {% for _attr in _attrs %} - {% unless _attr contains '=' %} - {% continue %} - {% endunless %} - - {% assign _pair = _attr | split: '="' %} - {% capture _key %}{{ _pair | first }}{% endcapture %} - {% capture _value %}{{ _pair | last | remove: '"' }}{% endcapture %} - - {% case _key %} - {% when 'src' %} - {% assign _src = _value %} - {% when 'lqip' %} - {% assign _lqip = _value %} - {% when 'class' %} - {% assign _class = _value %} - {% endcase %} - {% endfor %} - - - {% if _class %} - {% capture _old_class %}class="{{ _class }}"{% endcapture %} - {% assign _left = _left | remove: _old_class %} - {% endif %} - - {% assign _final_src = null %} - {% assign _lazyload = true %} - - {%- capture _img_url -%} - {% include img-url.html src=_src img_path=page.img_path %} - {%- endcapture -%} - - {% assign _path_prefix = _img_url | remove: _src %} - - {% unless _src contains '//' %} - {% assign _final_src = _path_prefix | append: _src %} - {% assign _src_alt = 'src="' | append: _path_prefix %} - {% assign _left = _left | replace: 'src="', _src_alt %} - {% endunless %} - - {% if _lqip %} - {% assign _lazyload = false %} - {% assign _class = _class | append: ' blur' %} - - {% unless _lqip contains 'data:' %} - {% assign _lqip_alt = 'lqip="' | append: _path_prefix %} - {% assign _left = _left | replace: 'lqip="', _lqip_alt %} - {% endunless %} - - - {% assign _left = _left | replace: 'src=', 'data-src=' | replace: ' lqip=', ' data-lqip="true" src=' %} - - {% else %} - {% assign _class = _class | append: ' shimmer' %} - {% endif %} - - - {% if _lazyload %} - {% assign _left = _left | append: ' loading="lazy"' %} - {% endif %} - - {% if page.layout == 'home' %} - - {% assign _wrapper_start = '
' %} - - {% assign _img_content = _img_content | append: _wrapper_start %} - {% assign _right = _right | prepend: '>` is wrapped by `` --> - {% assign _parent = _right | slice: 1, 4 %} - - {% if _parent == '' %} - - {% assign _size = _img_content | size | minus: 1 %} - {% capture _class %} - class="img-link{% unless _lqip %} shimmer{% endunless %}" - {% endcapture %} - {% assign _img_content = _img_content | slice: 0, _size | append: _class | append: '>' %} - - {% else %} - - {% assign _wrapper_start = _final_src - | default: _src - | prepend: '' - %} - - {% assign _img_content = _img_content | append: _wrapper_start %} - {% assign _right = '> - {% assign _img_content = _img_content | append: IMG_TAG | append: _left | append: _right %} - {% endfor %} - - {% if _img_content %} - {% assign _content = _img_content %} - {% endif %} -{% endif %} - - - -{% if _content contains '
' %} - {% assign _code_spippets = _content | split: '
' %} - {% assign _new_content = '' %} - - {% for _snippet in _code_spippets %} - {% if forloop.last %} - {% assign _new_content = _new_content | append: _snippet %} - - {% else %} - {% assign _left = _snippet | split: '><' | last %} - - {% if _left contains 'file="' %} - {% assign _label_text = _left | split: 'file="' | last | split: '"' | first %} - {% assign _label_icon = 'far fa-file-code fa-fw' %} - {% else %} - {% assign _lang = _left | split: 'language-' | last | split: ' ' | first %} - {% capture _label_text %}{% include language-alias.html language=_lang %}{% endcapture %} - {% assign _label_icon = 'fas fa-code fa-fw small' %} - {% endif %} - - {% capture _label %} - - {% endcapture %} - - {% assign _new_content = _new_content - | append: _snippet - | append: '
' - | append: _label - | append: '
' - | append: '
' - %} - {% endif %} - {% endfor %} - - {% assign _content = _new_content %} -{% endif %} - - - -{% assign heading_levels = '2,3,4,5' | split: ',' %} -{% assign _heading_content = _content %} - -{% for level in heading_levels %} - {% assign mark_start = '' - %} - - {% assign left = snippet | split: mark_end | first %} - {% assign right = snippet | slice: left.size, snippet.size %} - {% assign left = left | replace_first: '">', '">' | append: '' %} - - {% assign _new_content = _new_content | append: mark_start | append: left | append: anchor | append: right %} - {% endfor %} - - {% assign _heading_content = _new_content %} - {% endif %} -{% endfor %} - -{% assign _content = _heading_content %} - - -{{ _content }} diff --git a/_includes/related-posts.html b/_includes/related-posts.html deleted file mode 100644 index 1ba2f32..0000000 --- a/_includes/related-posts.html +++ /dev/null @@ -1,96 +0,0 @@ - - - -{% assign TOTAL_SIZE = 3 %} - - -{% assign TAG_SCORE = 1 %} - - -{% assign CATEGORY_SCORE = 0.5 %} - -{% assign SEPARATOR = ':' %} - -{% assign match_posts = '' | split: '' %} - -{% for category in page.categories %} - {% assign match_posts = match_posts | push: site.categories[category] | uniq %} -{% endfor %} - -{% for tag in page.tags %} - {% assign match_posts = match_posts | push: site.tags[tag] | uniq %} -{% endfor %} - -{% assign last_index = match_posts.size | minus: 1 %} -{% assign score_list = '' | split: '' %} - -{% for i in (0..last_index) %} - {% assign post = match_posts[i] %} - - {% if post.url == page.url %} - {% continue %} - {% endif %} - - {% assign score = 0 %} - - {% for tag in post.tags %} - {% if page.tags contains tag %} - {% assign score = score | plus: TAG_SCORE %} - {% endif %} - {% endfor %} - - {% for category in post.categories %} - {% if page.categories contains category %} - {% assign score = score | plus: CATEGORY_SCORE %} - {% endif %} - {% endfor %} - - {% if score > 0 %} - {% capture score_item %}{{ score }}{{ SEPARATOR }}{{ i }}{% endcapture %} - {% assign score_list = score_list | push: score_item %} - {% endif %} -{% endfor %} - -{% assign index_list = '' | split: '' %} - -{% if score_list.size > 0 %} - {% assign score_list = score_list | sort | reverse %} - {% for entry in score_list limit: TOTAL_SIZE %} - {% assign index = entry | split: SEPARATOR | last %} - {% assign index_list = index_list | push: index %} - {% endfor %} -{% endif %} - -{% assign relate_posts = '' | split: '' %} - -{% for index in index_list %} - {% assign i = index | to_integer %} - {% assign relate_posts = relate_posts | push: match_posts[i] %} -{% endfor %} - -{% if relate_posts.size > 0 %} - - -{% endif %} diff --git a/_includes/rent_vs_buy_blog_post.md b/_includes/rent_vs_buy_blog_post.md deleted file mode 100644 index 916fb12..0000000 --- a/_includes/rent_vs_buy_blog_post.md +++ /dev/null @@ -1,544 +0,0 @@ -```python -import pandas as pd -import numpy as np -import plotly.express as px -from scipy.optimize import minimize_scalar -import plotly.graph_objects as go -from IPython.display import display, Markdown - -from src.rent_vs_buy import RentVsBuy, rent_vs_buy_breakeven_objective_closure -``` - - -```python -# Helper functions. -def render_plotly_html(fig: go.Figure) -> None: - """Display a Plotly figure in markdown with HTML.""" - # Show the figure if in a IPython display. - fig.show() - # Render the content for html output. - display( - Markdown( - fig.to_html( - include_plotlyjs="cdn", - ) - ) - ) -``` - -## Setup -We can use `RentVsBuy`'s `calculate` function to simulate a financial scenario: - - -```python -# We will reuse these kwargs later on. -kwargs = dict( - home_price=915_000, - years=35, - mortgage_rate=0.06342, - downpayment=0.2, - length_of_mortgage=30, - home_price_growth_rate=0.03, - rent_growth_rate=0.025, - investment_return_rate=0.04, - inflation_rate=0.02, - filing_jointly=True, - property_tax_rate=0.0077, - marginal_tax_rate=0.02, - costs_of_buying_home=0.00, - costs_of_selling_home=0.06, - maintenance_rate=0.005, - home_owners_insurance_rate=0.0042, - monthly_utilities=0, - monthly_common_fees=358, - monthly_rent=3700, - security_deposit=1, - brokers_fee=0.00, - renters_insurance_rate=0.0132, -) -# Create our RentVsBuy calculator. -rent_vs_buy = RentVsBuy().calculate(**kwargs) -``` - -## Calculations -**High level overview** - -First, model the cash flows over the life of the home. These cashflows should incorporate any inflation or appreciation that occurs with time. For this we need: -- Value of the home -- Liabilities of the home -- Assets the home -- Liabilities of renting -- Assets of renting - -Next, we can calculate the opportunity cost of either renting or buying. This is the difference in money (i.e. $8000 monthly house payment - $3000 monthly rent payment) that we can invest for the remaining time of the home, appreciated at market rates. - -Below, we show the output of these various calculations for the given scenario. - -### Home Value -How much will the home be worth when we sell it? - - -```python -render_plotly_html( - px.line( - pd.DataFrame( - { - "Home Value": rent_vs_buy.home_value.flatten(), - "Initial Home Price": rent_vs_buy.home_value.flatten()[0], - } - ) - ) -) -``` - - - - - - - -
-
- - - - -### House Liabilities -What will we need to pay to upkeep the home? - - -```python -render_plotly_html( - px.line( - pd.DataFrame( - { - "Monthly Fees": rent_vs_buy.monthly_fees.flatten(), - "Insurance": rent_vs_buy.insurance.flatten(), - "Property Taxes": rent_vs_buy.property_taxes.flatten(), - "Maintenance": rent_vs_buy.maintenance.flatten(), - "Closing Costs": rent_vs_buy.buying_closing_costs.flatten(), - "Principal Payment": rent_vs_buy.ppmt.flatten(), - "Interest Payment": rent_vs_buy.ipmt.flatten(), - "Total Payment": rent_vs_buy.pmt.flatten(), - } - ) - ) -) -``` - - - - - - - -
-
- - - - -Or, cumulatively: - - -```python -render_plotly_html( - px.line( - pd.DataFrame( - { - "Total Cumulative Home Liabilities": rent_vs_buy.total_home_liability.flatten().cumsum(), - "Cumulative Principal": rent_vs_buy.ppmt.flatten().cumsum(), - "Cumulative Interest": rent_vs_buy.ipmt.flatten().cumsum(), - "Cumulative Payment": rent_vs_buy.pmt.flatten().cumsum(), - } - ) - ) -) -``` - - - - - - - -
-
- - - - -### House Assets -What money will the home bring in (besides the inherent value of the home)? This includes a tax credit for paying interest on a house (limited to 750K over the lifetime of the loan). - - -```python -render_plotly_html( - px.line( - pd.DataFrame({"Total Home Assets": rent_vs_buy.total_home_assets.flatten()}) - ) -) -``` - - - - - - - -
-
- - - - -### Rent Liabilities -What will renting cost us? Mostly, this is the rent payment. But also includes some other expenses that do not occur when buying a home. - - -```python -render_plotly_html( - px.line( - pd.DataFrame( - { - "Rent Payment": rent_vs_buy.rent.flatten(), - "Renters Insurance": rent_vs_buy.renters_insurance.flatten(), - "Security Deposit": rent_vs_buy.security_deposit_cost.flatten(), - "Brokers Fee": rent_vs_buy.brokers_fee_cost.flatten(), - "Total Rent Liability": rent_vs_buy.total_rent_liability.flatten(), - } - ) - ) -) -``` - - - - - - - -
-
- - - - -### Opportunity Costs -This is where we consider counterfactuals; if we didn't buy the house, how much could we earn in the market after we pay the rent? This goes both ways, depending on whether buying or renting is cheaper. - - -```python -render_plotly_html( - px.line( - pd.DataFrame( - { - "Home Cumulative Opportunity Cost": rent_vs_buy.home_cumulative_opportunity.flatten(), - "Rental Cumulative Opportunity Cost": rent_vs_buy.rental_cumulative_opportunity.flatten(), - } - ) - ) -) -``` - - - - - - - -
-
- - - - -## Advantage of Buying a Home instead of Renting -Here we hypothesis selling the home and "cashing out". This would be: - -```python -equity = house_value - remaining_loan_value - selling_fee -buy_vs_rent = equity + rental_cumulative_opportunity - home_cumulative_opportunity -``` - - -```python -render_plotly_html( - px.line( - pd.DataFrame( - {"Buy vs. Rent": rent_vs_buy.buy_vs_rent.flatten(), "Break Even": 0} - ) - ) -) -``` - - - - - - - -
-
- - - - -We see in this example, that we breakeven after 360 months, which is after the 30-year mortgage is paid off. - -## Optimize - -In addition to visualizing the cost curves, we can also use `scipy.optimize.minimize_scalar` to answer questions. If we only wanted to stay in the house for 5 years, what would be the optimal mortgage rate to breakeven on our investment? - - -```python -optimize_kwargs = kwargs.copy() -optimize_kwargs["years"] = 5 -``` - - -```python -minimize_scalar( - fun=rent_vs_buy_breakeven_objective_closure( - scalar="mortgage_rate", **optimize_kwargs - ), - bounds=[0.0001, 0.1], -) -``` - - - - - message: Solution found. - success: True - status: 0 - fun: 7.697306468326133 - x: 0.048066456702303674 - nit: 14 - nfev: 14 - - - -It seems we would need an interest rate of <0.05 for this to make sense. What about the downpayment? - - -```python -minimize_scalar( - fun=rent_vs_buy_breakeven_objective_closure( - scalar="downpayment", **optimize_kwargs - ), - bounds=[0.2, 1.0], -) -``` - - - - - message: Solution found. - success: True - status: 0 - fun: 0.10223317879717797 - x: 0.7087657693597916 - nit: 20 - nfev: 20 - - - -With keeping the house for only 5 years, we would need over 70% down to offset the opportunity cost of renting. The listed rent price is $3700, but is that a good deal? - - -```python -minimize_scalar( - fun=rent_vs_buy_breakeven_objective_closure( - scalar="monthly_rent", **optimize_kwargs - ), - # Exclude PMI for now. - bounds=[0, 5_000], -) -``` - - - - - message: Solution found. - success: True - status: 0 - fun: 0.00012648804113268852 - x: 4515.380553798023 - nit: 27 - nfev: 27 - - - -A rent price of $4515.38 would be equivalent with buying the house and keeping it for 5 years. So in this case, only paying $3700 during the same 5 year period is a good deal. - -## Vectorize -Since `numpy-financial` is a vectorized library, we can actually see the breakdown for a range of values. For example, we can visualize a 2-d surface between `home_price` and `mortgage_rate`: - - -```python -_x, _y = np.linspace(100_000, 2_000_000, 100), np.linspace(0.03, 0.1, 100) -x, y = np.meshgrid(_x, _y, indexing="ij") -x = x.flatten() -y = y.flatten() -surface_kwargs = kwargs.copy() -surface_kwargs.update({"home_price": x, "mortgage_rate": y}) -render_plotly_html( - px.imshow( - RentVsBuy().calculate(**surface_kwargs).value.reshape((100, 100)).T, - aspect="auto", - labels=dict(x="Home Price", y="Mortgage Rate", color="Break Even"), - x=_x, - y=_y, - ) -) -``` - - - - - - - -
-
- - - - -This graphic could help you time the market for various homes that are priced differently! - -## Simulate -It is even possible to do a simulation by sampling from prior distributions and then computing the distribution of break even values. This would be useful for analyzing the viability of a market or by imposing a "belief" over values instead of trusting just a single value like before. - - -```python -n = 10_000 -``` - - -```python -simulated_house_price = np.random.chisquare(5, n) * 100_000 + 500_000 -render_plotly_html(px.histogram(simulated_house_price, title="Simulated House Prices")) -``` - - - - - - - -
-
- - - - - -```python -simulated_mortgage_rates = np.random.beta(10, 5, n) * (0.07 - 0.02) + 0.02 -render_plotly_html(px.histogram(simulated_mortgage_rates, title="Mortgage Rate")) -``` - - - - - - - -
-
- - - - - -```python -simulated_downpayment = np.random.beta(5, 100, n) * (1.0 - 0.2) + 0.2 -render_plotly_html(px.histogram(simulated_downpayment, title="Downpayment")) -``` - - - - - - - -
-
- - - - - -```python -random_kwargs = kwargs.copy() -random_kwargs.update( - { - "home_price": simulated_house_price, - "mortgage_rate": simulated_mortgage_rates, - "downpayment": simulated_downpayment, - } -) -simulated_break_even = RentVsBuy().calculate(**random_kwargs).value -render_plotly_html(px.histogram(simulated_break_even, title="Simulated Break Even")) -# Print the p05, mean, and p95 of the distribution. -print( - "p05", - np.quantile(simulated_break_even, 0.05), - "\nMean", - simulated_break_even.mean(), - "\np95", - np.quantile(simulated_break_even, 0.95), -) -``` - - - - - - - -
-
- - - - - p05 -1754163.2511162711 - Mean 626641.8340161054 - p95 2122232.4632916385 - - -This simulated market seems like a good buy! You could possibly lose money, but on average you wont and the upshot is over 2M! - - -```python -# A little magic to automatically write my blog :) -import subprocess - -subprocess.run( - [ - "jupyter", - "nbconvert", - "--to", - "markdown", - "--output", - "~/jakee417.github.io/_includes/rent_vs_buy_blog_post.md", - "rent_vs_buy_blog_post.ipynb", - ] -) -``` - - [NbConvertApp] Converting notebook rent_vs_buy_blog_post.ipynb to markdown - /Users/jakeetaylor/opt/anaconda3/lib/python3.9/site-packages/nbconvert/filters/datatypefilter.py:39: UserWarning: Your element with mimetype(s) dict_keys(['application/vnd.plotly.v1+json']) is not able to be represented. - warn("Your element with mimetype(s) {mimetypes}" - [NbConvertApp] Writing 1263458 bytes to /Users/jakeetaylor/jakee417.github.io/_includes/rent_vs_buy_blog_post.md - - - - - - CompletedProcess(args=['jupyter', 'nbconvert', '--to', 'markdown', '--output', '~/jakee417.github.io/_includes/rent_vs_buy_blog_post.md', 'rent_vs_buy_blog_post.ipynb'], returncode=0) - - diff --git a/_includes/search-loader.html b/_includes/search-loader.html deleted file mode 100644 index be3ca8a..0000000 --- a/_includes/search-loader.html +++ /dev/null @@ -1,47 +0,0 @@ - - -{% capture result_elem %} -
-
-

{title}

- -
-

{snippet}

-
-{% endcapture %} - -{% capture not_found %}

{{ site.data.locales[include.lang].search.no_results }}

{% endcapture %} - - diff --git a/_includes/search-results.html b/_includes/search-results.html deleted file mode 100644 index c224c5f..0000000 --- a/_includes/search-results.html +++ /dev/null @@ -1,10 +0,0 @@ - - -
-
-
- {% include_cached trending-tags.html %} -
-
-
-
diff --git a/_includes/sidebar.html b/_includes/sidebar.html deleted file mode 100644 index b8f92e3..0000000 --- a/_includes/sidebar.html +++ /dev/null @@ -1,99 +0,0 @@ - - - - diff --git a/_includes/toc.html b/_includes/toc.html deleted file mode 100644 index 604d2c1..0000000 --- a/_includes/toc.html +++ /dev/null @@ -1,13 +0,0 @@ -{% assign enable_toc = false %} -{% if site.toc and page.toc %} - {% if page.content contains ' -

{{- site.data.locales[include.lang].panel.toc -}}

- - -{% endif %} diff --git a/_includes/topbar.html b/_includes/topbar.html deleted file mode 100644 index d85101a..0000000 --- a/_includes/topbar.html +++ /dev/null @@ -1,77 +0,0 @@ - - -
-
- - - - - -
- {% if page.layout == 'home' %} - {{- site.data.locales[include.lang].title | default: site.title -}} - {% elsif page.collection == 'tabs' or page.layout == 'page' %} - {%- capture tab_key -%}{{ page.url | split: '/' }}{%- endcapture -%} - {{- site.data.locales[include.lang].tabs[tab_key] | default: page.title -}} - {% else %} - {{- site.data.locales[include.lang].layout[page.layout] | default: page.layout | capitalize -}} - {% endif %} -
- - - - - - - - -
-
diff --git a/_includes/trending-tags.html b/_includes/trending-tags.html deleted file mode 100644 index 57369f0..0000000 --- a/_includes/trending-tags.html +++ /dev/null @@ -1,46 +0,0 @@ - - -{% assign MAX = 10 %} - -{% assign size_list = '' | split: '' %} -{% assign tag_list = '' | split: '' %} - -{% for tag in site.tags %} - {% assign size = tag | last | size %} - {% assign size_list = size_list | push: size %} - - {% assign tag_str = tag | first | append: '::' | append: size %} - {% assign tag_list = tag_list | push: tag_str %} -{% endfor %} - -{% assign size_list = size_list | sort | reverse %} - -{% assign tag_list = tag_list | sort_natural %} - -{% assign trending_tags = '' | split: '' %} - -{% for size in size_list limit: MAX %} - {% for tag_str in tag_list %} - {% assign tag = tag_str | split: '::' %} - {% assign tag_name = tag | first %} - {% assign tag_size = tag | last | plus: 0 %} - {% if tag_size == size %} - {% unless trending_tags contains tag_name %} - {% assign trending_tags = trending_tags | push: tag_name %} - {% break %} - {% endunless %} - {% endif %} - {% endfor %} -{% endfor %} - -{% if trending_tags.size > 0 %} -
-

{{- site.data.locales[include.lang].panel.trending_tags -}}

-
- {% for tag_name in trending_tags %} - {% assign url = tag_name | slugify | url_encode | prepend: '/tags/' | append: '/' %} - - {% endfor %} -
-
-{% endif %} diff --git a/_includes/update-list.html b/_includes/update-list.html deleted file mode 100644 index 93684c3..0000000 --- a/_includes/update-list.html +++ /dev/null @@ -1,40 +0,0 @@ - - -{% assign MAX_SIZE = 5 %} - -{% assign all_list = '' | split: '' %} - -{% for post in site.posts %} - {% assign datetime = post.last_modified_at | default: post.date %} - - {% capture elem %} - {{- datetime | date: "%Y%m%d%H%M%S" -}}::{{- forloop.index0 -}} - {% endcapture %} - - {% assign all_list = all_list | push: elem %} -{% endfor %} - -{% assign all_list = all_list | sort | reverse %} - -{% assign update_list = '' | split: '' %} - -{% for entry in all_list limit: MAX_SIZE %} - {% assign update_list = update_list | push: entry %} -{% endfor %} - -{% if update_list.size > 0 %} -
-

{{- site.data.locales[include.lang].panel.lastmod -}}

-
    - {% for item in update_list %} - {% assign index = item | split: '::' | last | plus: 0 %} - {% assign post = site.posts[index] %} - {% assign url = post.url | relative_url %} -
  • - {{ post.title }} -
  • - {% endfor %} -
-
- -{% endif %} diff --git a/_javascript/.DS_Store b/_javascript/.DS_Store deleted file mode 100644 index 2253d7e2128450f919fe4c7677e5114fae1a7a41..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 6148 zcmeHKJ5Iwu5S>XP;fR8iNHlu@n%uxdra+Xb=t3}p!j>(eh}H+;9u(9_+=!MpAM%ld zM1>H{NV9J}pB?+HXhK98RB$lHut&r%+LM7>#L2owMYr@&-A(5=O)okO zzmWmiy927Jp^{d#wSRSMw|lwlN7PMGEUQL5+0*!Baq;qcwlAvuMpSz*Z;Mysgk@+* zEj`k;y+@z-adf)zY}cpv`t9mj>w8|^Z0h#CJM~EGNzIU8AQ%V+{u2Y}*&^AYVT{2* zFc1u^8IbQof(qu2ouPg@Fz68gID%OPb2&>$PIAm0J41LNY^gv?Wj|uDrNf>)E_dt< zEuB~^V;!%|enMfb4tvsY;@mLCU?3RSWngHR6Y2lwU!VVXlj15E2nPNX13W6`#SD++ xy|wpn(rXiR0Tq$B&TyTAiMC?IN-I8ws=%IP0?ZvdLs%g3BcL?I5Dfe%10TC#M~eUe diff --git a/_javascript/_copyright b/_javascript/_copyright deleted file mode 100644 index 60a706b..0000000 --- a/_javascript/_copyright +++ /dev/null @@ -1 +0,0 @@ -Chirpy v<%= pkg.version %> | © 2019 <%= pkg.author %> | <%= pkg.license %> Licensed | <%= pkg.homepage %> diff --git a/_javascript/categories.js b/_javascript/categories.js deleted file mode 100644 index 15d8251..0000000 --- a/_javascript/categories.js +++ /dev/null @@ -1,7 +0,0 @@ -import { basic, initSidebar, initTopbar } from './modules/layouts'; -import { categoryCollapse } from './modules/plugins'; - -basic(); -initSidebar(); -initTopbar(); -categoryCollapse(); diff --git a/_javascript/commons.js b/_javascript/commons.js deleted file mode 100644 index 05a9765..0000000 --- a/_javascript/commons.js +++ /dev/null @@ -1,5 +0,0 @@ -import { basic, initSidebar, initTopbar } from './modules/layouts'; - -basic(); -initSidebar(); -initTopbar(); diff --git a/_javascript/home.js b/_javascript/home.js deleted file mode 100644 index 02948c9..0000000 --- a/_javascript/home.js +++ /dev/null @@ -1,8 +0,0 @@ -import { basic, initSidebar, initTopbar } from './modules/layouts'; -import { initLocaleDatetime, loadImg } from './modules/plugins'; - -basic(); -initSidebar(); -initTopbar(); -initLocaleDatetime(); -loadImg(); diff --git a/_javascript/misc.js b/_javascript/misc.js deleted file mode 100644 index c7a19d6..0000000 --- a/_javascript/misc.js +++ /dev/null @@ -1,7 +0,0 @@ -import { basic, initSidebar, initTopbar } from './modules/layouts'; -import { initLocaleDatetime } from './modules/plugins'; - -basic(); -initSidebar(); -initTopbar(); -initLocaleDatetime(); diff --git a/_javascript/modules/.DS_Store b/_javascript/modules/.DS_Store deleted file mode 100644 index f3396d5f2f1eaa8e07c3047c3fc58dd0cd6ae60f..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 6148 zcmeHKF;2r!47E!o0xTUFa|7rNLKRNX1vY4lU`Y6ppaT=xxd&#e zqm;2p1)b6js$9x1tX(0$bR*VlySsh8KhoMhol}O7s`{ha_3TSMF3x~6;0*j#2GFxb zk{w02&VV!E3^WYL_aTJ}W`?z5{B*#?5db)ZI||k^OGr*?m>JfJ*nzO70yULw#9&Q_ zKef2buvXM`VjDi#?#wo!aJ)OtPh&W7rs&oga0c28Z0O}k`u}17{NGOUD`&tN_*V?@ zFrVfVJd*X+&cjKsO`#`H5s9l6n-nZ!D@Lre;$3JI_)}Q`Gs9XD9*F-Dh%~ry27Z)* EcZ1 { - if ($window.scrollTop() > 50) { - $btn.fadeIn(); - } else { - $btn.fadeOut(); - } - }); - - $btn.on('click', () => { - $window.scrollTop(0); - }); -} diff --git a/_javascript/modules/components/category-collapse.js b/_javascript/modules/components/category-collapse.js deleted file mode 100644 index d6027a1..0000000 --- a/_javascript/modules/components/category-collapse.js +++ /dev/null @@ -1,36 +0,0 @@ -/** - * Tab 'Categories' expand/close effect. - */ -const childPrefix = 'l_'; -const parentPrefix = 'h_'; -const collapse = $('.collapse'); - -export function categoryCollapse() { - /* close up top-category */ - collapse.on('hide.bs.collapse', function () { - /* Bootstrap collapse events. */ const parentId = - parentPrefix + $(this).attr('id').substring(childPrefix.length); - if (parentId) { - $(`#${parentId} .far.fa-folder-open`).attr( - 'class', - 'far fa-folder fa-fw' - ); - $(`#${parentId} i.fas`).addClass('rotate'); - $(`#${parentId}`).removeClass('hide-border-bottom'); - } - }); - - /* expand the top category */ - collapse.on('show.bs.collapse', function () { - const parentId = - parentPrefix + $(this).attr('id').substring(childPrefix.length); - if (parentId) { - $(`#${parentId} .far.fa-folder`).attr( - 'class', - 'far fa-folder-open fa-fw' - ); - $(`#${parentId} i.fas`).removeClass('rotate'); - $(`#${parentId}`).addClass('hide-border-bottom'); - } - }); -} diff --git a/_javascript/modules/components/clipboard.js b/_javascript/modules/components/clipboard.js deleted file mode 100644 index 68f6afd..0000000 --- a/_javascript/modules/components/clipboard.js +++ /dev/null @@ -1,130 +0,0 @@ -/** - * Clipboard functions - * - * Dependencies: - * - popper.js (https://github.com/popperjs/popper-core) - * - clipboard.js (https://github.com/zenorocha/clipboard.js) - */ - -const clipboardSelector = '.code-header>button'; -const ICON_SUCCESS = 'fas fa-check'; -const ATTR_TIMEOUT = 'timeout'; -const ATTR_TITLE_SUCCEED = 'data-title-succeed'; -const ATTR_TITLE_ORIGIN = 'data-bs-original-title'; -const TIMEOUT = 2000; // in milliseconds - -function isLocked(node) { - if ($(node)[0].hasAttribute(ATTR_TIMEOUT)) { - let timeout = $(node).attr(ATTR_TIMEOUT); - if (Number(timeout) > Date.now()) { - return true; - } - } - return false; -} - -function lock(node) { - $(node).attr(ATTR_TIMEOUT, Date.now() + TIMEOUT); -} - -function unlock(node) { - $(node).removeAttr(ATTR_TIMEOUT); -} - -function getIcon(btn) { - let iconNode = $(btn).children(); - return iconNode.attr('class'); -} - -const ICON_DEFAULT = getIcon(clipboardSelector); - -function showTooltip(btn) { - const succeedTitle = $(btn).attr(ATTR_TITLE_SUCCEED); - $(btn).attr(ATTR_TITLE_ORIGIN, succeedTitle).tooltip('show'); -} - -function hideTooltip(btn) { - $(btn).tooltip('hide').removeAttr(ATTR_TITLE_ORIGIN); -} - -function setSuccessIcon(btn) { - let btnNode = $(btn); - let iconNode = btnNode.children(); - iconNode.attr('class', ICON_SUCCESS); -} - -function resumeIcon(btn) { - let btnNode = $(btn); - let iconNode = btnNode.children(); - iconNode.attr('class', ICON_DEFAULT); -} - -export function initClipboard() { - // Initial the clipboard.js object - if ($(clipboardSelector).length) { - const clipboard = new ClipboardJS(clipboardSelector, { - target(trigger) { - let codeBlock = trigger.parentNode.nextElementSibling; - return codeBlock.querySelector('code .rouge-code'); - } - }); - - const clipboardList = document.querySelectorAll(clipboardSelector); - [...clipboardList].map( - (elem) => - new bootstrap.Tooltip(elem, { - placement: 'left' - }) - ); - - clipboard.on('success', (e) => { - e.clearSelection(); - - const trigger = e.trigger; - if (isLocked(trigger)) { - return; - } - - setSuccessIcon(trigger); - showTooltip(trigger); - lock(trigger); - - setTimeout(() => { - hideTooltip(trigger); - resumeIcon(trigger); - unlock(trigger); - }, TIMEOUT); - }); - } - - /* --- Post link sharing --- */ - - const btnCopyLink = $('#copy-link'); - - btnCopyLink.on('click', (e) => { - let target = $(e.target); - - if (isLocked(target)) { - return; - } - - // Copy URL to clipboard - navigator.clipboard.writeText(window.location.href).then(() => { - const defaultTitle = target.attr(ATTR_TITLE_ORIGIN); - const succeedTitle = target.attr(ATTR_TITLE_SUCCEED); - // Switch tooltip title - target.attr(ATTR_TITLE_ORIGIN, succeedTitle).tooltip('show'); - lock(target); - - setTimeout(() => { - target.attr(ATTR_TITLE_ORIGIN, defaultTitle); - unlock(target); - }, TIMEOUT); - }); - }); - - btnCopyLink.on('mouseleave', function (e) { - const target = $(e.target); - target.tooltip('hide'); - }); -} diff --git a/_javascript/modules/components/img-loading.js b/_javascript/modules/components/img-loading.js deleted file mode 100644 index c9b7b7f..0000000 --- a/_javascript/modules/components/img-loading.js +++ /dev/null @@ -1,61 +0,0 @@ -/** - * Setting up image lazy loading and LQIP switching - */ - -const ATTR_DATA_SRC = 'data-src'; -const ATTR_DATA_LQIP = 'data-lqip'; - -const cover = { - SHIMMER: 'shimmer', - BLUR: 'blur' -}; - -function removeCover(clzss) { - $(this).parent().removeClass(clzss); -} - -function handleImage() { - if (!this.complete) { - return; - } - - if (this.hasAttribute(ATTR_DATA_LQIP)) { - removeCover.call(this, cover.BLUR); - } else { - removeCover.call(this, cover.SHIMMER); - } -} - -/** - * Switches the LQIP with the real image URL. - */ -function switchLQIP() { - const $img = $(this); - const src = $img.attr(ATTR_DATA_SRC); - - $img.attr('src', encodeURI(src)); - $img.removeAttr(ATTR_DATA_SRC); -} - -export function loadImg() { - const $images = $('article img'); - - if ($images.length) { - $images.on('load', handleImage); - } - - // Images loaded from the browser cache do not trigger the 'load' event - $('article img[loading="lazy"]').each(function () { - if (this.complete) { - removeCover.call(this, cover.SHIMMER); - } - }); - - // LQIPs set by the data URI or WebP will not trigger the 'load' event, - // so manually convert the URI to the URL of a high-resolution image. - const $lqips = $(`article img[${ATTR_DATA_LQIP}="true"]`); - - if ($lqips.length) { - $lqips.each(switchLQIP); - } -} diff --git a/_javascript/modules/components/img-popup.js b/_javascript/modules/components/img-popup.js deleted file mode 100644 index 7f78d99..0000000 --- a/_javascript/modules/components/img-popup.js +++ /dev/null @@ -1,22 +0,0 @@ -/** - * Set up image popup - * - * See: https://github.com/dimsemenov/Magnific-Popup - */ - -export function imgPopup() { - if ($('.popup') <= 0) { - return; - } - - $('.popup').magnificPopup({ - type: 'image', - closeOnContentClick: true, - showCloseBtn: false, - zoom: { - enabled: true, - duration: 300, - easing: 'ease-in-out' - } - }); -} diff --git a/_javascript/modules/components/locale-datetime.js b/_javascript/modules/components/locale-datetime.js deleted file mode 100644 index 214f2bf..0000000 --- a/_javascript/modules/components/locale-datetime.js +++ /dev/null @@ -1,51 +0,0 @@ -/** - * Update month/day to locale datetime - * - * Requirement: - */ - -/* A tool for locale datetime */ -class LocaleHelper { - static get attrTimestamp() { - return 'data-ts'; - } - - static get attrDateFormat() { - return 'data-df'; - } - - static get locale() { - return $('html').attr('lang').substring(0, 2); - } - - static getTimestamp(elem) { - return Number(elem.attr(LocaleHelper.attrTimestamp)); // unix timestamp - } - - static getDateFormat(elem) { - return elem.attr(LocaleHelper.attrDateFormat); - } -} - -export function initLocaleDatetime() { - dayjs.locale(LocaleHelper.locale); - dayjs.extend(window.dayjs_plugin_localizedFormat); - - $(`[${LocaleHelper.attrTimestamp}]`).each(function () { - const date = dayjs.unix(LocaleHelper.getTimestamp($(this))); - const text = date.format(LocaleHelper.getDateFormat($(this))); - $(this).text(text); - $(this).removeAttr(LocaleHelper.attrTimestamp); - $(this).removeAttr(LocaleHelper.attrDateFormat); - - // setup tooltips - const tooltip = $(this).attr('data-bs-toggle'); - if (typeof tooltip === 'undefined' || tooltip !== 'tooltip') { - return; - } - - const tooltipText = date.format('llll'); // see: https://day.js.org/docs/en/display/format#list-of-localized-formats - $(this).attr('data-bs-title', tooltipText); - new bootstrap.Tooltip($(this)); - }); -} diff --git a/_javascript/modules/components/mode-watcher.js b/_javascript/modules/components/mode-watcher.js deleted file mode 100644 index 7b2298a..0000000 --- a/_javascript/modules/components/mode-watcher.js +++ /dev/null @@ -1,21 +0,0 @@ -/** - * Add listener for theme mode toggle - */ -const $toggleElem = $('.mode-toggle'); - -export function modeWatcher() { - if ($toggleElem.length === 0) { - return; - } - - $toggleElem.off().on('click', (e) => { - const $target = $(e.target); - let $btn = - $target.prop('tagName') === 'button'.toUpperCase() - ? $target - : $target.parent(); - - modeToggle.flipMode(); // modeToggle: `_includes/mode-toggle.html` - $btn.trigger('blur'); // remove the clicking outline - }); -} diff --git a/_javascript/modules/components/search-display.js b/_javascript/modules/components/search-display.js deleted file mode 100644 index ad009c2..0000000 --- a/_javascript/modules/components/search-display.js +++ /dev/null @@ -1,122 +0,0 @@ -/** - * This script make #search-result-wrapper switch to unloaded or shown automatically. - */ -const $btnSbTrigger = $('#sidebar-trigger'); -const $btnSearchTrigger = $('#search-trigger'); -const $btnCancel = $('#search-cancel'); -const $content = $('#main-wrapper>.container>.row'); -const $topbarTitle = $('#topbar-title'); -const $search = $('search'); -const $resultWrapper = $('#search-result-wrapper'); -const $results = $('#search-results'); -const $input = $('#search-input'); -const $hints = $('#search-hints'); -const $viewport = $('html,body'); - -// class names -const C_LOADED = 'loaded'; -const C_UNLOADED = 'unloaded'; -const C_FOCUS = 'input-focus'; -const C_FLEX = 'd-flex'; - -class ScrollBlocker { - static offset = 0; - static resultVisible = false; - - static on() { - ScrollBlocker.offset = window.scrollY; - $viewport.scrollTop(0); - } - - static off() { - $viewport.scrollTop(ScrollBlocker.offset); - } -} - -/*--- Actions in mobile screens (Sidebar hidden) ---*/ -class MobileSearchBar { - static on() { - $btnSbTrigger.addClass(C_UNLOADED); - $topbarTitle.addClass(C_UNLOADED); - $btnSearchTrigger.addClass(C_UNLOADED); - $search.addClass(C_FLEX); - $btnCancel.addClass(C_LOADED); - } - - static off() { - $btnCancel.removeClass(C_LOADED); - $search.removeClass(C_FLEX); - $btnSbTrigger.removeClass(C_UNLOADED); - $topbarTitle.removeClass(C_UNLOADED); - $btnSearchTrigger.removeClass(C_UNLOADED); - } -} - -class ResultSwitch { - static on() { - if (!ScrollBlocker.resultVisible) { - // the block method must be called before $(#main-wrapper>.container) unloaded. - ScrollBlocker.on(); - $resultWrapper.removeClass(C_UNLOADED); - $content.addClass(C_UNLOADED); - ScrollBlocker.resultVisible = true; - } - } - - static off() { - if (ScrollBlocker.resultVisible) { - $results.empty(); - if ($hints.hasClass(C_UNLOADED)) { - $hints.removeClass(C_UNLOADED); - } - $resultWrapper.addClass(C_UNLOADED); - $content.removeClass(C_UNLOADED); - - // now the release method must be called after $(#main-wrapper>.container) display - ScrollBlocker.off(); - - $input.val(''); - ScrollBlocker.resultVisible = false; - } - } -} - -function isMobileView() { - return $btnCancel.hasClass(C_LOADED); -} - -export function displaySearch() { - $btnSearchTrigger.on('click', function () { - MobileSearchBar.on(); - ResultSwitch.on(); - $input.trigger('focus'); - }); - - $btnCancel.on('click', function () { - MobileSearchBar.off(); - ResultSwitch.off(); - }); - - $input.on('focus', function () { - $search.addClass(C_FOCUS); - }); - - $input.on('focusout', function () { - $search.removeClass(C_FOCUS); - }); - - $input.on('input', () => { - if ($input.val() === '') { - if (isMobileView()) { - $hints.removeClass(C_UNLOADED); - } else { - ResultSwitch.off(); - } - } else { - ResultSwitch.on(); - if (isMobileView()) { - $hints.addClass(C_UNLOADED); - } - } - }); -} diff --git a/_javascript/modules/components/sidebar.js b/_javascript/modules/components/sidebar.js deleted file mode 100644 index 9d8567e..0000000 --- a/_javascript/modules/components/sidebar.js +++ /dev/null @@ -1,25 +0,0 @@ -/** - * Expand or close the sidebar in mobile screens. - */ - -const $body = $('body'); -const ATTR_DISPLAY = 'sidebar-display'; - -class SidebarUtil { - static isExpanded = false; - - static toggle() { - if (SidebarUtil.isExpanded === false) { - $body.attr(ATTR_DISPLAY, ''); - } else { - $body.removeAttr(ATTR_DISPLAY); - } - - SidebarUtil.isExpanded = !SidebarUtil.isExpanded; - } -} - -export function sidebarExpand() { - $('#sidebar-trigger').on('click', SidebarUtil.toggle); - $('#mask').on('click', SidebarUtil.toggle); -} diff --git a/_javascript/modules/components/toc.js b/_javascript/modules/components/toc.js deleted file mode 100644 index b397813..0000000 --- a/_javascript/modules/components/toc.js +++ /dev/null @@ -1,13 +0,0 @@ -export function toc() { - if (document.querySelector('main h2, main h3')) { - // see: https://github.com/tscanlin/tocbot#usage - tocbot.init({ - tocSelector: '#toc', - contentSelector: '.content', - ignoreSelector: '[data-toc-skip]', - headingSelector: 'h2, h3, h4', - orderedList: false, - scrollSmooth: false - }); - } -} diff --git a/_javascript/modules/components/tooltip-loader.js b/_javascript/modules/components/tooltip-loader.js deleted file mode 100644 index a906600..0000000 --- a/_javascript/modules/components/tooltip-loader.js +++ /dev/null @@ -1,12 +0,0 @@ -/** - * Initial Bootstrap Tooltip. - */ -export function loadTooptip() { - const tooltipTriggerList = document.querySelectorAll( - '[data-bs-toggle="tooltip"]' - ); - - [...tooltipTriggerList].map( - (tooltipTriggerEl) => new bootstrap.Tooltip(tooltipTriggerEl) - ); -} diff --git a/_javascript/modules/layouts.js b/_javascript/modules/layouts.js deleted file mode 100644 index 28f7962..0000000 --- a/_javascript/modules/layouts.js +++ /dev/null @@ -1,3 +0,0 @@ -export { basic } from './layouts/basic'; -export { initSidebar } from './layouts/sidebar'; -export { initTopbar } from './layouts/topbar'; diff --git a/_javascript/modules/layouts/basic.js b/_javascript/modules/layouts/basic.js deleted file mode 100644 index fb36a8b..0000000 --- a/_javascript/modules/layouts/basic.js +++ /dev/null @@ -1,7 +0,0 @@ -import { back2top } from '../components/back-to-top'; -import { loadTooptip } from '../components/tooltip-loader'; - -export function basic() { - back2top(); - loadTooptip(); -} diff --git a/_javascript/modules/layouts/sidebar.js b/_javascript/modules/layouts/sidebar.js deleted file mode 100644 index 8795693..0000000 --- a/_javascript/modules/layouts/sidebar.js +++ /dev/null @@ -1,7 +0,0 @@ -import { modeWatcher } from '../components/mode-watcher'; -import { sidebarExpand } from '../components/sidebar'; - -export function initSidebar() { - modeWatcher(); - sidebarExpand(); -} diff --git a/_javascript/modules/layouts/topbar.js b/_javascript/modules/layouts/topbar.js deleted file mode 100644 index cfcd0ed..0000000 --- a/_javascript/modules/layouts/topbar.js +++ /dev/null @@ -1,5 +0,0 @@ -import { displaySearch } from '../components/search-display'; - -export function initTopbar() { - displaySearch(); -} diff --git a/_javascript/modules/plugins.js b/_javascript/modules/plugins.js deleted file mode 100644 index fb892e2..0000000 --- a/_javascript/modules/plugins.js +++ /dev/null @@ -1,6 +0,0 @@ -export { categoryCollapse } from './components/category-collapse'; -export { initClipboard } from './components/clipboard'; -export { loadImg } from './components/img-loading'; -export { imgPopup } from './components/img-popup'; -export { initLocaleDatetime } from './components/locale-datetime'; -export { toc } from './components/toc'; diff --git a/_javascript/page.js b/_javascript/page.js deleted file mode 100644 index f13bd2f..0000000 --- a/_javascript/page.js +++ /dev/null @@ -1,9 +0,0 @@ -import { basic, initSidebar, initTopbar } from './modules/layouts'; -import { loadImg, imgPopup, initClipboard } from './modules/plugins'; - -basic(); -initSidebar(); -initTopbar(); -loadImg(); -imgPopup(); -initClipboard(); diff --git a/_javascript/post.js b/_javascript/post.js deleted file mode 100644 index 86ea32b..0000000 --- a/_javascript/post.js +++ /dev/null @@ -1,17 +0,0 @@ -import { basic, initSidebar, initTopbar } from './modules/layouts'; -import { - loadImg, - imgPopup, - initLocaleDatetime, - initClipboard, - toc -} from './modules/plugins'; - -initSidebar(); -initTopbar(); -loadImg(); -imgPopup(); -initLocaleDatetime(); -initClipboard(); -toc(); -basic(); diff --git a/_javascript/pwa/app.js b/_javascript/pwa/app.js deleted file mode 100644 index 5add2d7..0000000 --- a/_javascript/pwa/app.js +++ /dev/null @@ -1,58 +0,0 @@ -/* PWA loader */ - -if ('serviceWorker' in navigator) { - const meta = document.querySelector('meta[name="pwa-cache"]'); - const isEnabled = meta.content === 'true'; - - if (isEnabled) { - let swUrl = '/sw.min.js'; - const baseUrl = meta.getAttribute('data-baseurl'); - - if (baseUrl !== null) { - swUrl = `${baseUrl}${swUrl}?baseurl=${encodeURIComponent(baseUrl)}`; - } - - const $notification = $('#notification'); - const $btnRefresh = $('#notification .toast-body>button'); - - navigator.serviceWorker.register(swUrl).then((registration) => { - // In case the user ignores the notification - if (registration.waiting) { - $notification.toast('show'); - } - - registration.addEventListener('updatefound', () => { - registration.installing.addEventListener('statechange', () => { - if (registration.waiting) { - if (navigator.serviceWorker.controller) { - $notification.toast('show'); - } - } - }); - }); - - $btnRefresh.on('click', () => { - if (registration.waiting) { - registration.waiting.postMessage('SKIP_WAITING'); - } - $notification.toast('hide'); - }); - }); - - let refreshing = false; - - // Detect controller change and refresh all the opened tabs - navigator.serviceWorker.addEventListener('controllerchange', () => { - if (!refreshing) { - window.location.reload(); - refreshing = true; - } - }); - } else { - navigator.serviceWorker.getRegistrations().then(function (registrations) { - for (let registration of registrations) { - registration.unregister(); - } - }); - } -} diff --git a/_javascript/pwa/sw.js b/_javascript/pwa/sw.js deleted file mode 100644 index cb2bdef..0000000 --- a/_javascript/pwa/sw.js +++ /dev/null @@ -1,101 +0,0 @@ -/* PWA service worker */ - -const swconfPath = '/assets/js/data/swconf.js'; -const params = new URL(location).searchParams; -const swconfUrl = params.has('baseurl') - ? `${params.get('baseurl')}${swconfPath}` - : swconfPath; - -importScripts(swconfUrl); -const purge = swconf.purge; - -function verifyHost(url) { - for (const host of swconf.allowHosts) { - const regex = RegExp(`^http(s)?://${host}/`); - if (regex.test(url)) { - return true; - } - } - return false; -} - -function verifyUrl(url) { - if (!verifyHost(url)) { - return false; - } - - const requestPath = new URL(url).pathname; - - for (const path of swconf.denyPaths) { - if (requestPath.startsWith(path)) { - return false; - } - } - return true; -} - -if (!purge) { - swconf.allowHosts.push(location.host); -} - -self.addEventListener('install', (event) => { - if (purge) { - return; - } - - event.waitUntil( - caches.open(swconf.cacheName).then((cache) => { - return cache.addAll(swconf.resources); - }) - ); -}); - -self.addEventListener('activate', (event) => { - event.waitUntil( - caches.keys().then((keyList) => { - return Promise.all( - keyList.map((key) => { - if (purge) { - return caches.delete(key); - } else { - if (key !== swconf.cacheName) { - return caches.delete(key); - } - } - }) - ); - }) - ); -}); - -self.addEventListener('message', (event) => { - if (event.data === 'SKIP_WAITING') { - self.skipWaiting(); - } -}); - -self.addEventListener('fetch', (event) => { - event.respondWith( - caches.match(event.request).then((response) => { - if (response) { - return response; - } - - return fetch(event.request).then((response) => { - const url = event.request.url; - - if (purge || event.request.method !== 'GET' || !verifyUrl(url)) { - return response; - } - - // See : - let responseToCache = response.clone(); - - caches.open(swconf.cacheName).then((cache) => { - cache.put(event.request, responseToCache); - }); - return response; - }); - }) - ); -}); diff --git a/assets/js/.DS_Store b/assets/js/.DS_Store deleted file mode 100644 index 93a1c499122d819c22795cf0a07cf9968e673ac5..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 6148 zcmeHKOHRWu5S@W6BC+X`1q&a5O;3PZg%flGtZ0b@NDZk(+4~6Gh7%z5NGy5d8E7mb zmI%R&WWVuzJjs({XNZXBPwkXwLPRx&Ad500VjguJSg<%*_E_Ie7dL&k8QJ8wn&jCl zYH3MZT9(gWzYTp|-!!Xrzk;paoj&X?UtVXWzx~#~xf^m5kech>(<5!mx>sjI->~jU zxCm)qH|KW!zV4X6totl=U7P`Dz!`7`{x<`-vqkD7MW3AkXTTZwWI)b`fFT$SlVUzP zFy$5iSizhHy7Ur~6AYtaQiKP>nhMlZwibgm9rj>x(J(1$IXQj}f9p3{N;BajL4$r<