Skip to content

Commit

Permalink
feat: add assetlinks
Browse files Browse the repository at this point in the history
  • Loading branch information
evan361425 committed Sep 23, 2023
1 parent 6c7e4ec commit 1843390
Show file tree
Hide file tree
Showing 8 changed files with 59 additions and 33 deletions.
1 change: 1 addition & 0 deletions .github/workflows/github-page.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ jobs:
- name: Install dependencies
run: |
pip install mkdocs
mkdocs --version
pip install mkdocs-material
pip install mkdocs-git-revision-date-localized-plugin
pip install -e lib
Expand Down
4 changes: 2 additions & 2 deletions .vscode/md.code-snippets
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"Tips": {
"Note": {
"scope": "markdown",
"prefix": "tips",
"prefix": "note",
"body": [
"${1|???,!!!|} ${2|info,note,tip,question,example,warning,failure,success,bug,danger,abstract,quote|} \"${3:title}\"",
"\t${4:body}"
Expand Down
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
# evan361425

Hi 我的資料整理處,詳見 [GitHub Page](https://evan361425.github.io)

## 客製 Plugins

為了滿足我的一些需求,自己寫了些 [plugins](./lib/),有需要歡迎取用:

- 在圖片下面加個標題;
- 在表格上面加個標題;
- 在本地端測試時,只建制特定文件,這樣不用每次重建一大堆東西。
22 changes: 8 additions & 14 deletions lib/evan361425/serve_simple.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,22 @@
Main plugin module for simply serve dev mode
"""

from json import load
from shutil import rmtree
from os import environ, getpid, listdir, path, symlink
from pathlib import Path
from mkdocs.config import config_options
from mkdocs.plugins import BasePlugin


# ------------------------
# Constants and utilities
# ------------------------
SETTING_NAME = "serve.json"

# ------------------------
# Plugin
# ------------------------
class MarkdownServeSimplePlugin(BasePlugin):
config_scheme = (
("dest", config_options.Type(str, default="site")),
("targets", config_options.Type(list, default=[])),
)

def on_config(self, config):
# only support on development
if (
Expand All @@ -29,8 +29,7 @@ def on_config(self, config):
pid = str(getpid())
src = config["docs_dir"] + "/"

setting = self.__parse_setting(config)
dest = replace_last_file(config["docs_dir"], setting["dest"])
dest = replace_last_file(config["docs_dir"], self.config["dest"])
config["docs_dir"] = dest

# Check exist
Expand All @@ -46,7 +45,7 @@ def on_config(self, config):
pid_f.write(pid)

# copy
for target in setting["targets"]:
for target in self.config["targets"]:
if target.find("/") != -1:
file_path = Path(path.join(dest, replace_last_file(target, "")))
file_path.mkdir(parents=True, exist_ok=True)
Expand All @@ -60,11 +59,6 @@ def on_config(self, config):

return config

def __parse_setting(self, config):
file_name = replace_last_file(config["config_file_path"], SETTING_NAME)
with open(file_name, encoding="utf-8") as json_file:
return load(json_file)


def replace_last_file(file_path: str, name: str):
index = file_path.rfind("/")
Expand Down
13 changes: 11 additions & 2 deletions mkdocs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ repo_name: GitHub
repo_url: https://github.com/evan361425/evan361425.github.io
edit_uri: blob/master/src/

# 避免把一些髒東西帶進網站,例如 .gitignore,但是我需要 .well-known 的資料
exclude_docs: |
!.well-known
nav:
- index.md
- 心得:
Expand Down Expand Up @@ -89,7 +93,6 @@ nav:
- Nginx 1.18 到 1.22 的差異: essay/nginx-changelog.md
- Node.js 14 到 18 的差異: essay/node-changelog-14-18.md
- 問卷設計指南: essay/questionnaire-principal.md

theme:
name: material
language: "zh-TW"
Expand Down Expand Up @@ -162,7 +165,13 @@ plugins:
- search
- figcaption
- tablecaption
- serve_simple
- serve_simple:
dest: site
targets:
- index.md
- latest-works.md
- javascripts/
- feedback/index.md
# Use it if need to glob
# - awesome-pages

Expand Down
15 changes: 0 additions & 15 deletions serve.json

This file was deleted.

12 changes: 12 additions & 0 deletions src/.well-known/assetlinks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[
{
"relation": ["delegate_permission/common.handle_all_urls"],
"target": {
"namespace": "android_app",
"package_name": "com.evanlu.possystem",
"sha256_cert_fingerprints": [
"9D:47:F3:5B:11:92:57:0B:A2:42:A6:FC:1E:99:56:76:F7:81:00:54:9A:EA:C1:0E:12:83:B0:10:B0:E6:1C:1B"
]
}
}
]
17 changes: 17 additions & 0 deletions src/feedback/site-reliability-workbook/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,20 @@ SRE 不一定是一個團隊,也可以是一種深入在開發團隊和維運
- [資料管線設計](./data-pipelines.md),資料管線幫助整合資料,其設計和線上系統有異曲同工之妙。
- [設定檔的最佳實踐](./configuration-best-practice.md),好的服務設定方式,會減少緊急情況的發生。
- [金絲雀部署](./canary-release.md),部署工程也是確保服務穩定的重要工具。

??? success "什麼是維運"
對我來說維運是困難的,但是必須要先釐清什麼是維運。

維持運作,不僅僅是功能出錯了修修補補,或者依賴套件版本更新,
更多的是你要去面對很多難以抉擇的選擇,例如:

- 服務流量上升了,從一台變成兩台之後,我要怎麼知道流量總量,500 的比例等等;
- 外部依賴從相同資料中心,搬遷到雲端,觀察到的 P99 延時拉高了,該怎麼處理;
- 每天固定某一時段,500 比例會升高,我該怎麼追蹤問題?

這些都是需要花時間,靜下來好好思考,摸索可能的原因和方案,和各個團隊溝通暸解,
最終的手段甚至只是個妥協方案,這些都再再考驗維運人員的智慧和經驗。

> 真正有效的工作方式,不是鐵人三項或馬拉松,比誰堅持的時間長,而是短跑,當機會來臨的時候衝刺,平時注意身體健康和休息。
>
> — Naval Ravikant

0 comments on commit 1843390

Please sign in to comment.