Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
26 changes: 26 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Build-blog
on:
push:
branches:
- main

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Setup python
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
architecture: x64
- name: Install requirements and build
run: |
pip install -r requirements.txt
python3 ./code/build.py
ls ./_build
- name: Deploy
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.PAT_BLOG }}
publish_dir: ./_build
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ __pycache__/
# Distribution / packaging
.Python
build/
_build/
develop-eggs/
dist/
downloads/
Expand Down
37 changes: 26 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,26 +1,41 @@
# BrainDataScienceBlog
This is a repository with the code and raw materials to build the [*Brain, Data, and Science*](http://diedrichsenlab.org/BrainDataScience) Blog. It is heavily build on the [Tufte.css](https://edwardtufte.github.io/tufte-css/) and the [markdown library](https://python-markdown.github.io/).

## Installation
## Automatic GH-pages deployment

### Step-0 Fork this repository ⑂

### Step-1 Create a GitHub access token 🔑

Please follow [these instructions](https://docs.github.com/en/free-pro-team@latest/github/authenticating-to-github/creating-a-personal-access-token#creating-a-token) to create an access token. While creating the token, you will only click the `repository` checkbox.

### Step-2 Create an encrypted secret for your repo 😎

Simply follow [these steps](https://docs.github.com/en/free-pro-team@latest/actions/reference/encrypted-secrets#creating-encrypted-secrets-for-a-repository) to create a **repository secret named `PAT_BLOG`**.

### Step-3 That's it!

If a secret is added successfully, a webpage build will be run by GitHub actions automatically and the webpage will be published online at: `your_gh_user_name.github.io/BrainDataScienceBlog` (unless you change the repository name).

You can test the build by simply changing the README file (remove the last line etc.). When you add more content following the [writing a new blog section](#writing-a-new-blog), those pages will be built automatically and added to your webpage!

## Local Installation

Fork or clone the [GitHub repository](https://github.com/DiedrichsenLab/BrainDataScienceBlog).

The repro required `python v >= 3.8`. You also need to have the following dependencies installed:
The repro required `python v >= 3.6`. You also need to have the following dependencies installed:

```
pip install markdown
pip install xml
pip install yaml
pip install pandas
pip install shutil
pip intall pybtex
pip install -r requirements.txt
```

## Building the webpage
## Building the webpage manually

A single Markdown file can be compiled to the target (`_build`) directory using:

A single Markdown file can be compiled to the target directory using:
`python3 ./code/build.py`

`python3 build.py`
If the build succeeds, you can see the webpage by opening `_build/index.htm` in your web browser.

## Writing a new blog

Expand Down
9 changes: 5 additions & 4 deletions code/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@
import shutil

# Source directory is the repository based
sourceDir = os.path.dirname(os.path.dirname(__file__))
sourceDir = os.path.abspath(os.path.join(os.path.dirname(os.path.abspath(__file__)),'..'))
# Build directory can be set here optionally - defaults to html in repository
buildDir = '/Users/jdiedrichsen/Dropbox (Diedrichsenlab)/Sites/Diedrichsenlab/BrainDataScience'
buildDir = os.path.join(sourceDir,'_build')
if not os.path.exists(buildDir):
buildDir = os.path.join(sourceDir,'html')
buildDir = os.path.join(sourceDir,'_build')
if not os.path.exists(buildDir):
os.makedirs(buildDir)

Expand Down Expand Up @@ -121,7 +121,8 @@ def main():
shutil.copy2(source,target)

# Build all the blogs in the list
with open("list.yaml", "r", encoding="utf-8") as list_file:
ymlFile = os.path.join(sourceDir,'list.yaml')
with open(ymlFile, "r", encoding="utf-8") as list_file:
listing = yaml.load(list_file,Loader=yaml.FullLoader)
info = []
for blog in listing['blogs']:
Expand Down
6 changes: 6 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
markdown
markdown-include
xml-python
pyyaml
pandas
pybtex