-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 9f229c9
Showing
17 changed files
with
1,179 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# For more information about the properties used in | ||
# this file, please see the EditorConfig documentation: | ||
# http://editorconfig.org/ | ||
# | ||
# Sensible EditorConfig defaults | ||
# https://gist.github.com/matijs/662bf45dd4ec37b3a068 | ||
root = true | ||
|
||
[*] | ||
charset = utf-8 | ||
end_of_line = lf | ||
indent_size = 2 | ||
indent_style = space | ||
insert_final_newline = true | ||
trim_trailing_whitespace = true | ||
|
||
# Make sure package.json always uses 2 spaces to indent | ||
[{package.json}] | ||
indent_size = 2 | ||
indent_style = space | ||
|
||
[{makefile, Makefile}] | ||
indent_style = tab |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
_book | ||
*.mobi | ||
*.epub | ||
node_modules | ||
output |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#!/bin/bash | ||
|
||
cur_ver=$(cat package.json | grep '"version":' | awk '{print $2}' | sed 's/"//g' | sed 's/,//g') | ||
new_ver=$(cat version) | ||
ver_pattern="\"version\": \"$cur_ver\"" # strict match to avoid accidently change dependency version | ||
ver_replacement="\"version\": \"$new_ver\"" | ||
cat package.json | sed "s/$ver_pattern/$ver_replacement/g" > package.json.tmp | ||
mv package.json.tmp package.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
NOW="$(date +'%B %d, %Y')" | ||
LATEST_HASH=`git log --pretty=format:'%h' -n 1` | ||
VERSION=version | ||
|
||
ADJUSTMENTS_MSG="${QUESTION_FLAG} ${CYAN}Now you can make adjustments to ${WHITE}CHANGELOG.md${CYAN}. Then press enter to continue." | ||
|
||
if [ -f $VERSION ]; then | ||
BASE_STRING=`cat $VERSION` | ||
BASE_LIST=(`echo $BASE_STRING | tr '.' ' '`) | ||
V_MAJOR=${BASE_LIST[0]} | ||
V_MINOR=${BASE_LIST[1]} | ||
V_PATCH=${BASE_LIST[2]} | ||
echo -e "${NOTICE_FLAG} Current version: ${WHITE}$BASE_STRING" | ||
echo -e "${NOTICE_FLAG} Latest commit hash: ${WHITE}$LATEST_HASH" | ||
V_MINOR=$((V_MINOR + 1)) | ||
V_PATCH=0 | ||
SUGGESTED_VERSION="$V_MAJOR.$V_MINOR.$V_PATCH" | ||
echo -ne "${QUESTION_FLAG} ${CYAN}Enter a version number [${WHITE}$SUGGESTED_VERSION${CYAN}]: " | ||
read INPUT_STRING | ||
if [ "$INPUT_STRING" = "" ]; then | ||
INPUT_STRING=$SUGGESTED_VERSION | ||
fi | ||
echo -e "${NOTICE_FLAG} Will set new version to be ${WHITE}$INPUT_STRING" | ||
echo $INPUT_STRING > $VERSION | ||
echo "## $INPUT_STRING ($NOW)" > tmpfile | ||
git log --pretty=format:" - %s" "v$BASE_STRING"...HEAD >> tmpfile | ||
echo "" >> tmpfile | ||
echo "" >> tmpfile | ||
cat CHANGELOG.md >> tmpfile | ||
mv tmpfile CHANGELOG.md | ||
echo -e "$ADJUSTMENTS_MSG" | ||
read | ||
git add CHANGELOG.md $VERSION | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
RELEASE_VERSION=v$(VERSION) | ||
GIT_BRANCH=$(strip $(shell git symbolic-ref --short HEAD)) | ||
GIT_VERSION="$(strip $(shell git rev-parse --short HEAD))" | ||
RELEASE_BODY=[release note](https://github.com/tyrchen/book_tianshu/blob/$(RELEASE_VERSION)/CHANGELOG.md#$(VERSION)-$(shell date +%B-%d-%Y | tr "[:upper:]" "[:lower:]") | ||
RELEASE_DATA='{"tag_name": "$(RELEASE_VERSION)", "name": "$(RELEASE_VERSION)", "target_commitish": "master", "body": "$(RELEASE_BODY))"}' | ||
RELEASE_URL=https://api.github.com/repos/tyrchen/book_tianshu/releases | ||
|
||
info: | ||
@echo $(RELEASE_DATA) | ||
|
||
release: all | ||
@git config --local user.name "Tyr Chen" | ||
@git config --local user.email "tyr.chen@gmail.com" | ||
@git tag -a $(RELEASE_VERSION) -m "Release $(RELEASE_VERSION). Revision is: $(GIT_VERSION)" || true | ||
@git push origin $(RELEASE_VERSION) || true | ||
@curl -s -d $(RELEASE_DATA) "$(RELEASE_URL)?access_token=$(GITHUB_TOKEN)" || true | ||
.makefiles/upload_asset.sh tag=$(RELEASE_VERSION) filename=$(OUTPUT)/$(RELEASE_FILENAME).pdf || true | ||
@.makefiles/upload_asset.sh tag=$(RELEASE_VERSION) filename=$(OUTPUT)/$(RELEASE_FILENAME).epub || true | ||
|
||
delete-release: | ||
@echo "Delete a release on $(RELEASE_VERSION)" | ||
@git tag -d $(RELEASE_VERSION) || true | ||
@git push -f -d origin $(RELEASE_VERSION) || true | ||
|
||
bump-version: | ||
@echo "Bump version..." | ||
@.makefiles/bump_version.sh | ||
|
||
create-pr: | ||
@echo "Creating pull request..." | ||
@make bump-version || true | ||
@git add CHANGELOG.md version;git commit -m "bump version" -n;git push origin $(GIT_BRANCH) | ||
@hub pull-request | ||
|
||
browse-pr: | ||
@hub browse -- pulls |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
#!/usr/bin/env bash | ||
# | ||
# Author: Stefan Buck | ||
# License: MIT | ||
# https://gist.github.com/stefanbuck/ce788fee19ab6eb0b4447a85fc99f447 | ||
# | ||
# | ||
# This script accepts the following parameters: | ||
# | ||
# * tag | ||
# * filename | ||
# | ||
# Script to upload a release asset using the GitHub API v3. | ||
# | ||
# Example: | ||
# | ||
# upload-github-release-asset.sh ag=v0.1.0 filename=./build.zip | ||
# | ||
|
||
# Check dependencies. | ||
set -e | ||
xargs=$(which gxargs || which xargs) | ||
|
||
# Validate settings. | ||
[ "$TRACE" ] && set -x | ||
|
||
CONFIG=$@ | ||
|
||
for line in $CONFIG; do | ||
eval "$line" | ||
done | ||
|
||
# Define variables. | ||
owner=tyrchen | ||
repo=book_tianshu | ||
|
||
GH_API="https://api.github.com" | ||
GH_REPO="$GH_API/repos/$owner/$repo" | ||
GH_TAGS="$GH_REPO/releases/tags/$tag" | ||
AUTH="Authorization: token $GITHUB_TOKEN" | ||
WGET_ARGS="--content-disposition --auth-no-challenge --no-cookie" | ||
CURL_ARGS="-LJO#" | ||
|
||
if [[ "$tag" == 'LATEST' ]]; then | ||
GH_TAGS="$GH_REPO/releases/latest" | ||
fi | ||
|
||
# Validate token. | ||
curl -o /dev/null -sH "$AUTH" $GH_REPO || { echo "Error: Invalid repo, token or network issue!"; exit 1; } | ||
|
||
# Read asset tags. | ||
response=$(curl -sH "$AUTH" $GH_TAGS) | ||
id=$(echo $response | jq .id) | ||
echo $id | ||
|
||
# Upload asset | ||
echo "Uploading asset... " | ||
|
||
# Construct url | ||
GH_ASSET="https://uploads.github.com/repos/$owner/$repo/releases/$id/assets?name=$(basename $filename)" | ||
|
||
echo $GH_ASSET | ||
|
||
curl "$GITHUB_OAUTH_BASIC" --data-binary @"$filename" -H "Authorization: token $GITHUB_TOKEN" -H "Content-Type: application/octet-stream" $GH_ASSET |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
PANDOC=pandoc --lua-filter templates/pagebreak.lua -t html5 --mathjax --template=templates/github.wechat --tab-stop 2 --highlight-style pygments --standalone --section-divs | ||
|
||
VERSION=$(strip $(shell cat version)) | ||
OUTPUT=output | ||
SRC=src | ||
RES=resources | ||
SRC_DIRS=$(basename $(shell find src -maxdepth 1 -mindepth 1 -type d)) | ||
RES_DIRS=$(basename $(shell find resources -maxdepth 1 -mindepth 1 -type d)) | ||
DOCS=$(shell find src -name "*.md") | ||
RES_DOCS=$(shell find resources -name "*.md") | ||
OUTPUT_DIRS=$(SRC_DIRS:$(SRC)/%=$(OUTPUT)/%) $(RES_DIRS:$(RES)/%=$(OUTPUT)/%) | ||
HTMLS=$(DOCS:$(SRC)/%.md=$(OUTPUT)/%.html) | ||
RESOURCES=$(RES_DOCS:$(RES)/%.md=$(OUTPUT)/%.html) | ||
BOOK_HTML=$(OUTPUT)/book.html | ||
RELEASE_FILENAME=tchen | ||
|
||
all: build post-build | ||
|
||
init: install dep | ||
@echo "Initializing the repo..." | ||
|
||
travis-init: | ||
@echo "Initialize software required for travis (normally ubuntu software)" | ||
|
||
show: | ||
@echo $(HTMLS) $(RESOURCES) $(SRC_DIRS) $(OUTPUT_DIRS) | ||
|
||
install: | ||
@echo "Install software required for this repo..." | ||
@brew install pandoc | ||
@mix local.rebar --force | ||
|
||
dep: | ||
@echo "Install dependencies required for this repo..." | ||
@npm install -g chrome-headless-render-pdf | ||
|
||
pre-build: dep | ||
@echo "Running scripts before the build..." | ||
|
||
post-build: | ||
@echo "Running scripts after the build is done..." | ||
@make pdf | ||
@make epub | ||
|
||
travis: all | ||
|
||
travis-deploy: | ||
@echo "Deploy the software by travis" | ||
@make release | ||
|
||
build: $(OUTPUT) copy-assets $(HTMLS) $(RESOURCES) | ||
|
||
clean: | ||
@rm -rf $(OUTPUT)/*/*/*.html $(OUTPUT)/intro.html $(OUTPUT)/book.html | ||
|
||
copy-assets: | ||
@rsync -arv $(SRC)/* $(RES)/* $(OUTPUT) --exclude '*.md' | ||
|
||
$(OUTPUT): $(OUTPUT_DIRS) | ||
|
||
$(OUTPUT_DIRS): | ||
mkdir -p $@ | ||
|
||
watch: | ||
@echo "Watching templates and slides changes..." | ||
@fswatch -o $(SRC)/ $(RES)/ templates/*/* | xargs -n1 -I{} make build | ||
|
||
pdf: $(BOOK_HTML) | ||
@chrome-headless-render-pdf --window-size 1600x1200 --include-background --url file://$(PWD)/$(BOOK_HTML) --pdf $(OUTPUT)/$(RELEASE_FILENAME).pdf | ||
|
||
epub: $(BOOK_HTML) | ||
@cd $(OUTPUT); pandoc --mathjax book.html -o $(RELEASE_FILENAME).epub | ||
|
||
run: | ||
@http-server $(OUTPUT) -p 8000 -c-1 | ||
|
||
$(BOOK_HTML):$(DOCS) | ||
@$(PANDOC) $(DOCS) -o $(BOOK_HTML).tmp | ||
@sed 's/src="\//src="/g' $(BOOK_HTML).tmp > $(BOOK_HTML) | ||
|
||
$(DIRECTORIES):$(OUTPUT)/%:$(SRC) | ||
|
||
$(HTMLS):$(OUTPUT)/%.html:$(SRC)/%.md | ||
@echo "Creating doc $@ with file $<." | ||
-@$(PANDOC) $< -o $@ | ||
|
||
$(RESOURCES):$(OUTPUT)/%.html:$(RES)/%.md | ||
@echo "Creating doc $@ with file $<." | ||
-@$(PANDOC) $< -o $@ | ||
|
||
|
||
include .makefiles/*.mk | ||
|
||
.PHONY: build copy-assets watch run mv |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# 程序君的公众号 | ||
|
||
公众号文章,按照《天叔奇谈》的组织方式,每周出一个版本。 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
# Summary | ||
|
||
* [Introduction](README.md) | ||
* [前言](src/intro.md) | ||
* 19 年第 37 周(09/09) | ||
* [数学:蚂蚁和蚂蚁药](src/2019/w37/3-math-ants.md) | ||
* [探索:世界上有多少人?](src/2019/w37/4-explore-population.md) | ||
* [纪录片:神奇的月球](src/2019/w37/5-documentary-moon.md) | ||
* [几何:测量π](src/2019/w37/6-geometry-pi.md) | ||
* [掷骰子:Sratch Jr 重新入门](src/2019/w37/7-dice-scratch.md) | ||
* 19 年第 38 周(09/16) | ||
* [历史故事:三家分晋](src/2019/w38/1-story-jin.md) | ||
* [数学:数字游戏背后的数学](src/2019/w38/2-math-magic.md) | ||
* [Scratch:自由发挥](src/2019/w38/3-scratch-freeform.md) | ||
* [探索:植物为什么有阳光和水就能长大?](src/2019/w38/4-explore-how-plant-grows.md) | ||
* [纪录片:数学地图](src/2019/w38/5-documentary-the-map-of-math.md) | ||
* [几何:尺规作图](src/2019/w38/6-geometry-ruler-and-compass-construction.md) | ||
* [探索:为什么玩 monkey bar 手上会磨出泡?](src/2019/w38/7-explore-monkey-bar.md) | ||
* 19 年第 39 周(09/23) | ||
* [历史故事:魏文侯,李克和吴起](src/2019/w39/1-story-wei.md) | ||
* [数学:进制](src/2019/w39/2-math-positional-notation.md) | ||
* [Scratch:跳舞的小女孩](src/2019/w39/3-scratch-ballerina.md) | ||
* [探索:为什么吃的东西那么香,拉出来的大臭那么臭?](src/2019/w39/4-explore-poop.md) | ||
* [纪录片:数学的历史](src/2019/w39/5-documentary-history-of-math.md) | ||
* [几何:勾股定理](src/2019/w39/6-geometry-gougu.md) | ||
* [scratch:我和我的祖国](src/2019/w39/7-scratch-my-country.md) | ||
* 19 年第 40 周(09/30) | ||
* [历史故事:中国近代史](src/2019/w40/1-chinese-modern-history.md) | ||
* [数学:24 点游戏](src/2019/w40/2-math-24-game.md) | ||
* Scratch: 升国旗 | ||
* [探索: 为什么一盘菜,表面的很快就变凉了?](src/2019/w40/4-explore-temperature.md) | ||
* [纪录片:人类简史](src/2019/w40/5-documentary-human-history.md) | ||
* 几何:尺规作图加减乘除 | ||
* 掷色子 | ||
* 19 年第 41 周(10/07) | ||
* [数学:揭秘数字](src/2019/w41/2-math-number-reveal.md) | ||
* [Scratch: 电动升旗不能保证万无一失](src/2019/w41/3-scratch-flag-raising.md) | ||
* [探索:为什么汽车不用推可以自己走?](src/2019/w41/4-explore-car-engine.md) | ||
* [纪录片:终极密码 - 形状](src/2019/w41/5-documentary-the-code-2.md) | ||
* [几何:尺规作图加减乘除](src/2019/w41/6-geometry-ruler-and-compass-construction-2.md) | ||
* [scratch:迷宫 - 基础篇](src/2019/w41/7-scratch-maze-1.md) | ||
* 19 年第 42 周(10/14) | ||
* [历史故事:田氏代齐](src/2019/w42/1-story-tian-qi.md) | ||
* [数学:揭秘数字 II](src/2019/w42/2-math-number-reveal-2.md) | ||
* [Scratch: pinball I](src/2019/w42/3-scratch-pin-ball.md) | ||
* [探索:为什么钢琴能发出好听的声音?](src/2019/w42/4-explore-why-piano.md) | ||
* [纪录片:伟大的作曲家:莫扎特](src/2019/w42/5-documentary-mozart.md) | ||
* [几何:基本概念和角](src/2019/w42/6-geometry-basic-concepts.md) | ||
* [纪录片:终极密码 - 预测](src/2019/w42/7-documentary-the-code-3.md) | ||
* 19 年第 43 周(10/21) | ||
* [历史故事: 各国的富国强兵之路](src/2019/w43/1-story-fuguo.md) | ||
* [数学:最大公约数和最小公倍数](src/2019/w43/2-math-gcd-lcm.md) | ||
* [Scratch: pinball II](src/2019/w43/3-scratch-pin-ball-2.md) | ||
* [探索:水为什么能烧开?](src/2019/w43/4-explore-water-boiling.md) | ||
* [纪录片:数学漫步第一季](src/2019/w43/5-documentary-dimension-1.md) | ||
* [几何:基本概念(续)](src/2019/w43/6-geometry-basic-concepts-2.md) | ||
* [纪录片:数学漫步第二季](src/2019/w43/7-documentary-chaos-1.md) | ||
* 19 年第 44 周(10/28) | ||
* [历史故事:商鞅变法](src/2019/w44/1-story-shangyang.md) | ||
* [数学:有趣的斐波那契数列 I](src/2019/w44/2-math-fibonacci-series-1.md) | ||
* [Scratch: pinball III](src/2019/w44/3-scratch-pin-ball-3.md) | ||
* [探索:铅笔是怎么做出来的?](src/2019/w44/4-explore-how-pencils-are-made.md) | ||
* [几何:勾股定理的伟大作用](src/2019/w44/6-geometry-pythagorean-theorem-usage.md) | ||
* [数学:x 进制的加减乘除](src/2019/w44/7-arithmetic-for-carry-system.md) | ||
* 19 年第 45 周(11/04) | ||
* [历史故事:齐威王,孙膑,庞涓和田忌](src/2019/w45/1-story-sunbin.md) | ||
* [数学:有趣的斐波那契数列 II](src/2019/w45/2-math-fibonacci-series-2.md) | ||
* [Scratch: 太阳系](src/2019/w45/3-scratch-solar-system.md) | ||
* [探索:种子是怎么发育成植物的?](src/2019/w45/4-explore-germination.md) | ||
* [纪录片:逻辑学的乐趣](src/2019/w45/5-documentary-logic.md) | ||
* [几何: 全等和相似](src/2019/w45/6-geometry-simularity.md) | ||
* 19 年第 46 周(11/11) | ||
* [历史故事:诸子百家 I](src/2019/w46/1-story-baijia-1.md) | ||
* [数学:进入虚无之地 —— 代数(基本原理和概念)](src/2019/w46/2-math-algebra-1.md) | ||
* [Scratch: 敲砖块 I](src/2019/w46/3-scratch-bricks-1.md) | ||
* [几何:距离](src/2019/w46/6-geometry-distance.md) | ||
* 19 年第 47 周(11/18) | ||
* [历史故事:诸子百家 II](src/2019/w47/1-story-baijia-2.md) | ||
* [数学:进入虚无之地 —— 代数(坐标轴和方程)](src/2019/w47/2-math-algebra-2.md) | ||
* [Scratch: 敲砖块 II](src/2019/w47/3-scratch-bricks-2.md) | ||
* 19 年第 48 周(11/25) | ||
* [历史故事:公孙衍,张仪和苏秦](src/2019/w48/1-story-zonghengjia.md) | ||
* [数学:进入虚无之地 —— 代数(函数和序列)](src/2019/w48/2-math-algebra-3.md) | ||
* [Scratch: 敲砖块 III](src/2019/w48/3-scratch-bricks-3.md) | ||
* 19 年第 49 周(12/02) | ||
* [历史故事:孟尝君和四大公子](src/2019/w49/1-story-menchangjun.md) | ||
* [数学:进入虚无之地 —— 代数(指数,对数和复数)](src/2019/w49/2-math-algebra-4.md) | ||
* [Scratch: 超级马里奥 I](src/2019/w49/3-scratch-super-mario-1.md) | ||
* 19 年第 50 周(12/09) | ||
* [历史故事:六国三次合纵伐秦](src/2019/w50/1-story-faqin.md) | ||
* [数学:进入虚无之地 —— 代数( 简单三角函数)](src/2019/w50/2-math-algebra-5.md) | ||
* [Scratch: 超级马里奥 II](src/2019/w50/3-scratch-super-mario-2.md) | ||
* 19 年第 51 周(12/16) | ||
* [历史故事:司马错伐蜀](src/2019/w51/1-story-fashu.md) | ||
* [数学:排列组合和概率 I](src/2019/w51/2-math-probability-1.md) | ||
* [Scratch: 超级马里奥 III](src/2019/w51/3-scratch-super-mario-3.md) | ||
* 19 年第 52 周(12/23) | ||
* [历史故事:子之之乱及燕昭王招贤纳士](src/2019/w52/1-story-yanzhaowang.md) | ||
* [数学:排列组合和概率 II](src/2019/w52/2-math-probability-2.md) | ||
* [Scratch: 超级马里奥 IV](src/2019/w52/3-scratch-super-mario-4.md) | ||
* 19 年第 53 周/20 年第 1 周(12/30) | ||
* [历史故事:赵武灵王](src/2019/w53/1-story-zhaowulinwang.md) | ||
* [数学:排列组合和概率 III](src/2019/w53/2-math-probability-3.md) | ||
* [Scratch: 超级马里奥 V](src/2019/w53/3-scratch-super-mario-5.md) |
Oops, something went wrong.