-
Notifications
You must be signed in to change notification settings - Fork 65
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
Changes from 41 commits
9b68a8e
0ee41eb
20565cf
c418703
bf35dbb
cb47fdb
416a34f
1e455a0
9faa7ff
90b1e38
db46932
c141d98
0d8f409
edcb8a8
6ce819c
eef8dc0
72d1882
becb02f
757c695
5064303
356398d
049f41b
406c17d
1f6d021
a75a537
ccdec08
9096ec6
35fbd29
f309096
fd0053b
10409a7
d1fff58
6f50232
6ec1f61
72af71b
09583f9
78993cb
5ef7202
b05bae8
59f1742
c8ab758
d3c303a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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 |
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}} | ||
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' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. There was a problem hiding this comment. Choose a reason for hiding this commentThe 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), ' ') | ||
) | ||
}} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -266,4 +266,5 @@ cover.pdf | |
sjtubeamer*.pdf | ||
cover-*.pdf | ||
basis-*.tex | ||
step*.pdf | ||
step*.pdf | ||
contrib/*/*.pdf |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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. |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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)