Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

contrib: add community contrib feature #79

Merged
merged 42 commits into from
Jan 30, 2022
Merged
Show file tree
Hide file tree
Changes from 41 commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
9b68a8e
feat: add usemytheme & getcontribpath/dir command
LogCreative Dec 1, 2021
0ee41eb
contrib: add sjtug template
LogCreative Dec 1, 2021
20565cf
feat: add my test case
LogCreative Dec 1, 2021
c418703
Revert "feat: add my test case"
LogCreative Dec 3, 2021
bf35dbb
docs: fix dtx #
LogCreative Dec 3, 2021
cb47fdb
feat: add test case for contrib
LogCreative Dec 3, 2021
416a34f
feat: current path & multiple mytheme
LogCreative Dec 3, 2021
1e455a0
docs: minor tweak
LogCreative Dec 3, 2021
9faa7ff
feat: pass options to mytheme
LogCreative Dec 3, 2021
90b1e38
docs: passing options
LogCreative Dec 3, 2021
db46932
fix: update the method
LogCreative Dec 5, 2021
c141d98
fix: underful box
LogCreative Dec 7, 2021
0d8f409
ci: fix indent
LogCreative Dec 12, 2021
edcb8a8
ci: detect theme name and compile
LogCreative Dec 16, 2021
6ce819c
ci: covert to png
LogCreative Dec 20, 2021
eef8dc0
ci: comment on pr
LogCreative Dec 20, 2021
72d1882
ci: fix indent
LogCreative Dec 20, 2021
becb02f
docs: add CONTRIBUTING.md
LogCreative Dec 20, 2021
757c695
ci: use Chinese prompt
LogCreative Dec 24, 2021
5064303
ci: run in env
LogCreative Dec 24, 2021
356398d
ci: fix contrib yml
LogCreative Dec 24, 2021
049f41b
ci: chmod +x
LogCreative Dec 24, 2021
406c17d
ci: fix contrib yml +1
LogCreative Dec 24, 2021
1f6d021
ci: fix contrib regex
LogCreative Dec 24, 2021
a75a537
ci: install git
LogCreative Dec 24, 2021
ccdec08
ci: fix git
LogCreative Dec 24, 2021
9096ec6
ci: fix git diff branch
LogCreative Dec 24, 2021
35fbd29
ci: fetch all branches
LogCreative Dec 24, 2021
f309096
ci: try reply to issue
LogCreative Dec 28, 2021
fd0053b
ci: try fix issue comment
LogCreative Dec 28, 2021
10409a7
ci: solidate the action
LogCreative Dec 28, 2021
d1fff58
ci: final fix issue comment
LogCreative Dec 28, 2021
6f50232
docs: dev guide on plugin contrib
LogCreative Dec 30, 2021
6ec1f61
docs: user guide on plugin
LogCreative Dec 30, 2021
72af71b
ci: fix indent
LogCreative Dec 30, 2021
09583f9
bump version to 2.5.0
LogCreative Dec 30, 2021
78993cb
docs: add bibtex example
LogCreative Dec 31, 2021
5ef7202
ci: fix indent
LogCreative Dec 31, 2021
b05bae8
ci: fix build path
LogCreative Dec 31, 2021
59f1742
ci: fix build path+1
LogCreative Dec 31, 2021
c8ab758
new copyright year 2022
LogCreative Dec 31, 2021
d3c303a
update issue number
LogCreative Jan 30, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions .github/ci/build_contrib.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# !/bin/bash

mapfile themes <contrib.txt
# All contrib template should only have one entry point.
for theme in ${themes[@]};
do
theme=${theme:1:${#theme}-2} # remove the /
echo Compiling $theme documentation...
cp contrib/$theme/$theme.tex ./$theme.tex
latexmk $@ -outdir=build $theme.tex
echo Compiling $theme preview ...
sed -e "s|<theme>|$theme|g" src/doc/contrib.template.tex > build/contrib.$theme.tex
latexmk $@ -outdir=build build/contrib.$theme.tex
echo Converting $theme to png...
convert -verbose -density 500 -resize '1280' build/contrib.$theme.pdf build/contrib.$theme.png
done
6 changes: 6 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,16 @@ on:
branches:
- main
- develop
paths:
- '**'
- '!contrib/**'
pull_request:
branches:
- main
- develop
paths:
- '**'
- '!contrib/**'

name: Build

Expand Down
91 changes: 91 additions & 0 deletions .github/workflows/contrib.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
on:
push:
branches:
- main
paths:
- 'contrib/**'
pull_request:
branches:
- main
- develop
types:
- 'review_requested'
paths:
- 'contrib/**'

name: Contrib

jobs:
build-contrib:
runs-on: ubuntu-latest
# permission to the environment will
# need to be approved by one of the collaborators
environment: IMGUR
steps:
- uses: actions/checkout@v2
name: checkout code
with:
fetch-depth: 0
- name: get newly contributed package
run: |
git diff origin/main --name-only | grep -e 'contrib\/[^/]*\/sjtubeamertheme[^/]*\.ltx' | grep -o -e '\/[^/]*\/' > contrib.txt
- uses: xu-cheng/texlive-action/full@v1
with:
run: |
apk add ghostscript imagemagick gnupg
sed -i "s|<policy domain=\"coder\" rights=\"none\" pattern=\"PDF\" />|<policy domain=\"coder\" rights=\"read\|write\" pattern=\"PDF\" />|g" /etc/ImageMagick-*/policy.xml
.github/ci/build_contrib.sh -halt-on-error -time -quiet -xelatex
name: build contrib doc with XeLaTeX
- uses: actions/upload-artifact@v2
with:
path: |
build/contrib.*.pdf
name: upload contrib artifacts
- uses: devicons/public-upload-to-imgur@v2.2.2
id: contrib_png
with:
path: ./build/contrib.*.png
client_id: ${{secrets.IMGUR_CLIENT_ID}}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Everyone who creates PR can now access this secret. Is it expected?

Copy link
Contributor Author

@LogCreative LogCreative Jan 16, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems that if someone pulls a request, then collaborator approves it, the secret could be accessed. (idk)

name: upload contrib img to imgur
- uses: jungwinter/comment@v1
if: github.event_name == 'pull_request'
env:
MESSAGE: |
Thank you for contributing to SJTUBeamer!

Here is the preview of your contribution documentation.

{0}
with:
type: create
issue_number: ${{ github.event.number }}
token: ${{ secrets.GITHUB_TOKEN }}
body: >
${{
format(
env.MESSAGE,
join(fromJSON(steps.contrib_png.outputs.markdown_urls), ' ')
)
}}
- uses: jungwinter/comment@v1
if: github.event_name == 'push'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we really need to comment on pushes? I would prefer only doing comments on pull-requests.

Copy link
Contributor Author

@LogCreative LogCreative Jan 16, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The intention here is to make a collection of templates in an issue so that the user could select the theme in an easier way. Since the doc of the plug-in will not be included in the repo. It is a workaround for that.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And it has not been tested.

env:
MESSAGE: |
###{0}

@{1}

{2}
with:
type: create
issue_number: '77' # to be replaced by the good first issue number, open issues only.
token: ${{ secrets.GITHUB_TOKEN }}
body: >
${{
format(
env.MESSAGE,
github.event.push.commits[0].message,
github.event.push.commits[0].author.name,
join(fromJSON(steps.contrib_png.outputs.markdown_urls), ' ')
)
}}
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -266,4 +266,5 @@ cover.pdf
sjtubeamer*.pdf
cover-*.pdf
basis-*.tex
step*.pdf
step*.pdf
contrib/*/*.pdf
1 change: 1 addition & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
24 changes: 21 additions & 3 deletions .vscode/sjtubeamer.code-snippets

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

36 changes: 36 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# 向 SJTUBeamer 贡献插件

SJTUBeamer 现在已经开放插件接口,存放于根目录的 `contrib/` 文件夹中。如果您实现了自己的主题模板,或者是基于 SJTUBeamer API 的宏包,可以考虑通过下面的步骤向本存储库发 PR:
1. fork 仓库,克隆自己的仓库到本地。
2. 向你的电脑安装当前版本的 SJTUBeamer,`cd src && l3build install`,便于插件文档的编写。
3. 在 `contrib` 文件夹中新建一个插件文件夹 `<theme>`
4. 在文件夹中至少应该有下面两个文件:
- 插件入口 `contrib/<theme>/sjtubeamertheme<theme>.ltx`
- 插件文档 `contrib/<theme>/<theme>.tex`
5. 如果在插件中需要使用相对于该插件目录的文件,请使用下面的 API:
- `\getcontribdir{<theme>}` 返回插件目录 `contrib/<theme>`
- `\getcontribpath{<theme>}{<filepath>}` 返回插件文件 `contrib/<theme>/<filepath>`
6. 发 PR 时,使用 `contrib: <theme>` 作为标题,并向维护者发出代码审查请求。
7. 之后在根目录的主文件中就可以在 `\usetheme{sjtubeamer}` 后使用 `\usemytheme{<theme>}` 调用你的插件。

更多信息,请参阅开发文档。

-----

# Contribute to SJTUBeamer

SJTUBeamer is available for receiving plugins, which are stored in `contrib/` folder. If you want to contribute your own theme template or package based on SJTUBeamer API, you could make a pull request to this repo by the following steps:
1. Fork this repository and clone your own version to the machine.
2. Install the current version of `SJTUBeamer` to your computer for the convenience of writing documentation.
`cd src && l3build install`.
3. Create a new plugin folder `<theme>` in `contrib`.
4. At least two files should be implemented in the folder:
- Plugin entry point. `contrib/<theme>/sjtubeamertheme<theme>.ltx`
- Plugin documentation. `contrib/<theme>/<theme>.tex`
5. If you want to use the file in your plugin directory, use the following API:
- `\getcontribdir{<theme>}` returns the plugin directory `contrib/<theme>`
- `\getcontribpath{<theme>}{<filepath>}` returns plugin file path `contrib/<theme>/<filepath>`
6. Pull request to this repo naming `contrib: <theme>`, request a review from one of the collaborators.
7. Now, you could call your plugin by using `\usemytheme{<theme>}` after `\usetheme{sjtubeamer}`.

For more information, please refer to the development guide.
4 changes: 2 additions & 2 deletions beamercolorthemesjtubeamer.sty

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

4 changes: 2 additions & 2 deletions beamerfontthemesjtubeamer.sty

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

4 changes: 2 additions & 2 deletions beamerinnerthemesjtubeamer.sty

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

4 changes: 2 additions & 2 deletions beamerouterthemesjtubeamer.sty

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

22 changes: 20 additions & 2 deletions beamerthemesjtubeamer.sty

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

Loading