Skip to content

Commit

Permalink
Add Sitemap and Banner-Generator
Browse files Browse the repository at this point in the history
  • Loading branch information
rockleona committed Oct 1, 2023
1 parent 693214e commit 566b5a1
Show file tree
Hide file tree
Showing 9 changed files with 110 additions and 0 deletions.
10 changes: 10 additions & 0 deletions _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -103,3 +103,13 @@ theme: frame
## Docs: https://hexo.io/docs/one-command-deployment
deploy:
type: ''

# Sitemap
sitemap:
path:
- sitemap.xml
template: ./sitemap_template.xml
# template_txt: ./sitemap_template.txt
rel: false
tags: true
categories: true
24 changes: 24 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"hexo-generator-archive": "^2.0.0",
"hexo-generator-category": "^2.0.0",
"hexo-generator-index": "^3.0.0",
"hexo-generator-sitemap": "^3.0.1",
"hexo-generator-tag": "^2.0.0",
"hexo-renderer-ejs": "^2.0.0",
"hexo-renderer-marked": "^6.1.1",
Expand Down
40 changes: 40 additions & 0 deletions sitemap_template.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
{% for post in posts %}
<url>
<loc>{{ post.permalink | uriencode }}</loc>
{% if post.updated %}
<lastmod>{{ post.updated | formatDate }}</lastmod>
{% elif post.date %}
<lastmod>{{ post.date | formatDate }}</lastmod>
{% endif %}
<changefreq>monthly</changefreq>
<priority>0.6</priority>
</url>
{% endfor %}

<url>
<loc>{{ config.url | uriencode }}</loc>
<lastmod>{{ sNow | formatDate }}</lastmod>
<changefreq>daily</changefreq>
<priority>1.0</priority>
</url>

{% for tag in tags %}
<url>
<loc>{{ tag.permalink | uriencode }}</loc>
<lastmod>{{ sNow | formatDate }}</lastmod>
<changefreq>weekly</changefreq>
<priority>0.2</priority>
</url>
{% endfor %}

{% for cat in categories %}
<url>
<loc>{{ cat.permalink | uriencode }}</loc>
<lastmod>{{ sNow | formatDate }}</lastmod>
<changefreq>weekly</changefreq>
<priority>0.2</priority>
</url>
{% endfor %}
</urlset>
1 change: 1 addition & 0 deletions source/_posts/hello-world.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
---
title: Hello, World
date: 2023-09-11 22:00:00
sitemap: false
tags:
- murmur
---
Expand Down
34 changes: 34 additions & 0 deletions source/_posts/kktix-banner-generator.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
---
title: KKTIX Banner Generator (活動旗幟產生器)
date: 2023-10-01 11:29:33
tags:
- dev
- marketing
---

[上次文章](https://hi.rockleon.dev/blog/2023/09/11/visualize-first-try/)中有提到加入了 pydoc 翻譯計畫,在 2023 / 10月舉辦一個實體活動,本次是第一次實際餐與籌備,所以意外的接觸到了 KKTIX 後台。

[python-docs-zh-tw](https://github.com/python/python-docs-zh-tw) 翻譯計畫是 [sciwork](https://sciwork.dev/) 社群所支持的專案之一,很多所需的資源都是仰賴 sciwork 的基礎建設而成的,包含這次的售票系統的 KKTIX 也由他們提供。

在 KKTIX 的後台中,提供了活動圖片的上傳空間,同時間他也會代表 html meta tag 的圖片,同時意味著,如果在社群媒體平台分享的話,可以有個小縮圖可以看到圖片是甚麼。

在社群沒有平面設計師協助的情況之下,小弟我自告奮勇地寫了一個 Banner Generator:

{% asset_img banner-pydoc.png [banner-pydoc] %}
> [python-docs-zh-tw](https://github.com/python/python-docs-zh-tw) 2023/10 sprint
Generator 的腳本中,我使用了以下的 techstack (當然是 developed with Python):
1. [Pillow](https://pillow.readthedocs.io/en/stable/): 圖片編輯
2. [Unsplash API](https://unsplash.com/documentation): 隨機圖片的提供者

其中遇到的幾個有趣小東西值得紀錄一下:
1. Unsplash API 取得相片 URL 後,Requests GET 所得到的會直接是 Bytes 而不是 String,原本挖 Stack Overflow 的時候,有看到一個 Reference 指出需要用 StringIO 實作解析圖片, **我被誤導了** ,明明看過相片 URL 本身依定會回傳 Bytes,為甚麼還要用 StringIO 去解析呢?? **(暈頭轉向的我)**
2. 如果是合成透明圖片 (圖層) 的話,一定要用上 ```Image.alpha_composite()```,不然你的圖片會有很精美的方格子出現,也就是大家最喜歡的 png 透明圖層具現化(?)

{% asset_img code_bytesio.png [code_bytesio] %}
> Using PIL.Image to open ByteIO Binary Image
{% asset_img code_alphalayer.png [code_alphalayer] %}
> Image.alpha_composite() to composite the image
以上就是這次的開發小記,之後有公開的 Repository 再更新上來,總計 2 個小時研究及將 PoC 開發完畢,甚是感動。
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 566b5a1

Please sign in to comment.