Skip to content

Commit

Permalink
upgrade fastpages
Browse files Browse the repository at this point in the history
  • Loading branch information
goodboychan committed Jul 22, 2021
1 parent c4b489d commit 67f6c90
Show file tree
Hide file tree
Showing 17 changed files with 75 additions and 31 deletions.
24 changes: 23 additions & 1 deletion .github/workflows/check_config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,26 @@ jobs:
})
env:
ERROR_STRING: "You have not configured your baseurl correctly, please read the instructions in _config.yml carefully."
RUN_ID: ${{ github.run_id }}
RUN_ID: ${{ github.run_id }}

- name: check for User Pages
id: userpage
run: |
import os
nwo = os.getenv('GITHUB_REPOSITORY')
errmsg = "fastpages does not support User Pages or repo names that end with github.io, please see https://forums.fast.ai/t/fastpages-replacing-main-username-github-io-page-w-fastpages/64316/3 for more details."
assert ".github.io" not in nwo, errmsg
shell: python

- name: Create Issue if User Pages rule is violated
if: steps.userpage.outcome == 'failure'
uses: actions/[email protected]
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
github.issues.create({
owner: context.repo.owner,
repo: context.repo.repo,
title: "Error with repository configuration: repo name",
body: 'fastpages does not support User Pages or repo names that end with github.io, please see https://forums.fast.ai/t/fastpages-replacing-main-username-github-io-page-w-fastpages/64316/3 for more details.'
})
2 changes: 1 addition & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: CI
on:
push:
branches:
- main # need to filter here so we only deploy when there is a push to master
- master # need to filter here so we only deploy when there is a push to master
# no filters on pull requests, so intentionally left blank
pull_request:
workflow_dispatch:
Expand Down
15 changes: 7 additions & 8 deletions .github/workflows/setup.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ jobs:
nwo = os.getenv('GITHUB_REPOSITORY')
username, repo_name = nwo.split('/')
baseurl = '' if repo_name == f'{username}.github.io' else f'/{repo_name}'
readme_template_path = Path('_fastpages_docs/README_TEMPLATE.md')
readme_path = Path('README.md')
config_path = Path('_config.yml')
Expand All @@ -39,25 +38,25 @@ jobs:
# edit settings.ini file to inject baseurl
config.read(settings)
config['DEFAULT']['baseurl'] = baseurl
config['DEFAULT']['baseurl'] = f'/{repo_name}'
with open('_action_files/settings.ini', 'w') as configfile:
config.write(configfile)
# replace content of README with template
readme = readme_template_path.read_text().replace('{_username_}', username).replace('{_repo_name_}', repo_name).replace('{_baseurl_}', baseurl)
readme = readme_template_path.read_text().replace('{_username_}', username).replace('{_repo_name_}', repo_name)
readme_path.write_text(readme)
# update _config.yml
cfg = config_path.read_text()
cfg = re.sub(r'^(github_username: )(fastai)', fr'\g<1>{username}', cfg, flags=re.MULTILINE)
cfg = re.sub(r'^(baseurl: )("")', fr'\1"{baseurl}"', cfg, flags=re.MULTILINE)
cfg = re.sub(r'^(github_repo: ")(fastpages)', fr'\1{repo_name}', cfg, flags=re.MULTILINE)
cfg = re.sub(r'^(baseurl: )("")', r'\1"/{}"'.format(repo_name), cfg, flags=re.MULTILINE)
cfg = re.sub(r'^(github_repo: ")(fastpages)', r'\1{}'.format(repo_name), cfg, flags=re.MULTILINE)
cfg = re.sub(r'^(url: "https://)(fastpages.fast.ai)(")', fr'\g<1>{username}.github.io\3', cfg, flags=re.MULTILINE)
cfg = re.sub('UA-57531313-5', '', cfg, flags=re.MULTILINE)
config_path.write_text(cfg)
# prepare the pr message
pr = pr_msg_path.read_text().replace('{_username_}', username).replace('{_repo_name_}', repo_name).replace('{_baseurl_}', baseurl)
pr = pr_msg_path.read_text().replace('{_username_}', username).replace('{_repo_name_}', repo_name)
pr_msg_path.write_text(pr)
shell: python

Expand All @@ -83,7 +82,7 @@ jobs:
git rm .github/ISSUE_TEMPLATE/feature_request.md
git rm _word/*.docx
git add _config.yml README.md _fastpages_docs/ _action_files/settings.ini
git commit -m 'Setup repo'
git commit -m'setup repo'
git push -f --set-upstream origin fastpages-automated-setup
env:
GH_EMAIL: ${{ github.event.commits[0].author.email }}
Expand All @@ -101,6 +100,6 @@ jobs:
repo: context.repo.repo,
title: 'Initial Setup',
head: 'fastpages-automated-setup',
base: 'main',
base: 'master',
body: `${contents}`
})
4 changes: 2 additions & 2 deletions .github/workflows/upgrade.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ jobs:
git checkout -b fastpages-automated-upgrade
git add -A
git commit -m'upgrade fastpages'
git push -f --set-upstream origin fastpages-automated-upgrade main
git push -f --set-upstream origin fastpages-automated-upgrade master
env:
GH_USERNAME: ${{ github.event.issue.user.login }}

Expand All @@ -207,7 +207,7 @@ jobs:
repo: context.repo.repo,
title: '[fastpages] Update repo with changes from fastpages',
head: 'fastpages-automated-upgrade',
base: 'main',
base: 'master',
body: `${contents}`
})
.then(result => console.log(`::set-output name=pr_num::${result.data.number}`))
Expand Down
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ GEM
jekyll-seo-tag (~> 2.1)
minitest (5.14.2)
multipart-post (2.1.1)
nokogiri (1.11.7)
nokogiri (1.11.5)
mini_portile2 (~> 2.5.0)
racc (~> 1.4)
octicons (11.0.0)
Expand Down
2 changes: 1 addition & 1 deletion _action_files/settings.ini
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[DEFAULT]
lib_name = nbdev
user = fastai
branch = main
branch = master
version = 0.2.10
description = Writing a library entirely in notebooks
keywords = jupyter notebook
Expand Down
6 changes: 6 additions & 0 deletions _fastpages_docs/TROUBLESHOOTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,10 @@ See the [Upgrading guide](https://github.com/fastai/fastpages/blob/master/_fastp

2. Can you customize the styling or theme of fastpages? **A**: See [Customizing Fastpages](https://github.com/fastai/fastpages#customizing-fastpages)

3. Your initial build failed on GH-Pages Status

`Error messsage: Unable to build page. Please try again later.` `Error: Process completed with exit code 1.`

If your github username contains capital letters e.g. YourUserName, go to [config file](../_config.yml#L17) line 17 and rename `YourUserName.github.io` to `yourusername.github.io`. After the commit blog should build without error.

See the [FAQ](https://github.com/fastai/fastpages#faq) for frequently asked questions.
10 changes: 5 additions & 5 deletions _fastpages_docs/_setup_pr_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,22 @@ Hello :wave: @goodboychan! Thank you for using fastpages!

1. Create an ssh key-pair. Open <a href="https://8gwifi.org/sshfunctions.jsp" target="_blank">this utility</a>. Select: `RSA` and `4096` and leave `Passphrase` blank. Click the blue button `Generate-SSH-Keys`.

2. Navigate to <a href="https://github.com/goodboychan/chans_jupyter/settings/secrets" target="_blank">this link</a> and click `New repository secret`. Copy and paste the **Private Key** into the `Value` field. This includes the "---BEGIN RSA PRIVATE KEY---" and "--END RSA PRIVATE KEY---" portions. **In the `Name` field, name the secret `SSH_DEPLOY_KEY`.**
2. Navigate to <a href="https://github.com/goodboychan/goodboychan.github.io/settings/secrets" target="_blank">this link</a> and click `New repository secret`. Copy and paste the **Private Key** into the `Value` field. This includes the "---BEGIN RSA PRIVATE KEY---" and "--END RSA PRIVATE KEY---" portions. **In the `Name` field, name the secret `SSH_DEPLOY_KEY`.**

3. Navigate to <a href="https://github.com/goodboychan/chans_jupyter/settings/keys" target="_blank">this link</a> and click the `Add deploy key` button. Paste your **Public Key** from step 1 into the `Key` box. In the `Title`, name the key anything you want, for example `fastpages-key`. Finally, **make sure you click the checkbox next to `Allow write access`** (pictured below), and click `Add key` to save the key.
3. Navigate to <a href="https://github.com/goodboychan/goodboychan.github.io/settings/keys" target="_blank">this link</a> and click the `Add deploy key` button. Paste your **Public Key** from step 1 into the `Key` box. In the `Title`, name the key anything you want, for example `fastpages-key`. Finally, **make sure you click the checkbox next to `Allow write access`** (pictured below), and click `Add key` to save the key.

![](https://raw.githubusercontent.com/fastai/fastpages/master/_fastpages_docs/_checkbox.png)


### What to Expect After Merging This PR

- GitHub Actions will build your site, which will take 2-3 minutes to complete. **This will happen anytime you push changes to the master branch of your repository.** You can monitor the logs of this if you like on the [Actions tab of your repo](https://github.com/goodboychan/chans_jupyter/actions).
- GitHub Actions will build your site, which will take 2-3 minutes to complete. **This will happen anytime you push changes to the master branch of your repository.** You can monitor the logs of this if you like on the [Actions tab of your repo](https://github.com/goodboychan/goodboychan.github.io/actions).
- Your GH-Pages Status badge on your README will eventually appear and be green, indicating your first successful build.
- You can monitor the status of your site in the GitHub Pages section of your [repository settings](https://github.com/goodboychan/chans_jupyter/settings).
- You can monitor the status of your site in the GitHub Pages section of your [repository settings](https://github.com/goodboychan/goodboychan.github.io/settings).

If you are not using a custom domain, your website will appear at:

#### https://goodboychan.github.io/chans_jupyter
#### https://goodboychan.github.io/goodboychan.github.io


## Optional: Using a Custom Domain
Expand Down
4 changes: 2 additions & 2 deletions _fastpages_docs/_upgrade_pr.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ If you would like more fine-grained control over what changes to accept or decli

### What to Expect After Merging This PR

- GitHub Actions will build your site, which will take 3-4 minutes to complete. **This will happen anytime you push changes to the master branch of your repository.** You can monitor the logs of this if you like on the [Actions tab of your repo](https://github.com/goodboychan/chans_jupyter/actions).
- You can monitor the status of your site in the GitHub Pages section of your [repository settings](https://github.com/goodboychan/chans_jupyter/settings).
- GitHub Actions will build your site, which will take 3-4 minutes to complete. **This will happen anytime you push changes to the master branch of your repository.** You can monitor the logs of this if you like on the [Actions tab of your repo](https://github.com/goodboychan/goodboychan.github.io/actions).
- You can monitor the status of your site in the GitHub Pages section of your [repository settings](https://github.com/goodboychan/goodboychan.github.io/settings).
2 changes: 1 addition & 1 deletion _fastpages_docs/version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.1.45
2.1.48
2 changes: 0 additions & 2 deletions _includes/custom-head.html
Original file line number Diff line number Diff line change
Expand Up @@ -61,5 +61,3 @@
elem.forEach(e => (e.innerHTML = '<i class="fas fa-link fa-xs"></i>'));
});
</script>

<script data-ad-client="ca-pub-6747875619665490" async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
1 change: 1 addition & 0 deletions _includes/google-analytics.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,5 @@

gtag('config', '{{site.google_analytics}}');
</script>

{% endif %}
2 changes: 1 addition & 1 deletion _includes/notebook_binder_link.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<div class="px-2">
<a href="https://mybinder.org/v2/gh/{{site.github_username}}/{{site.github_repo | default: site.baseurl | remove: "/" }}/{{page.branch | default: "main"}}?filepath={{page.nb_path | url_encode }}" target="_blank">
<a href="https://mybinder.org/v2/gh/{{site.github_username}}/{{site.github_repo | default: site.baseurl | remove: "/" }}/{{page.branch | default: "master"}}?filepath={{page.nb_path | url_encode }}" target="_blank">
<img class="notebook-badge-image" src="{{ "assets/badges/binder.svg" | relative_url }}" alt="Open In Binder"/>
</a>
</div>
4 changes: 2 additions & 2 deletions _includes/notebook_colab_link.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<div class="px-2">
<a href="https://colab.research.google.com/github/{{site.github_username}}/{{site.github_repo | default: site.baseurl | remove: "/" }}/blob/{{page.branch | default: "main"}}/{{page.nb_path}}" target="_blank">
<a href="https://colab.research.google.com/github/{{site.github_username}}/{{site.github_repo | default: site.baseurl | remove: "/" }}/blob/{{page.branch | default: "master"}}/{{page.nb_path}}" target="_blank">
<img class="notebook-badge-image" src="{{ "assets/badges/colab.svg" | relative_url }}" alt="Open In Colab"/>
</a>
</div>
</div>
4 changes: 2 additions & 2 deletions _includes/notebook_github_link.html
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<div class="px-2">
{% if page.layout == 'notebook' %}
<a href="https://github.com/{{site.github_username}}/{{site.github_repo | default: site.baseurl | remove: "/" }}/tree/{{page.branch | default: "main" }}/{{page.nb_path}}" role="button" target="_blank">
<a href="https://github.com/{{site.github_username}}/{{site.github_repo | default: site.baseurl | remove: "/" }}/tree/{{page.branch | default: "master" }}/{{page.nb_path}}" role="button" target="_blank">
{% elsif page.layout == 'post' %}
<a href="https://github.com/{{site.github_username}}/{{site.github_repo | default: site.baseurl | remove: "/" }}/tree/{{page.branch | default: "main" }}/{{page.path}}" role="button" target="_blank">
<a href="https://github.com/{{site.github_username}}/{{site.github_repo | default: site.baseurl | remove: "/" }}/tree/{{page.branch | default: "master" }}/{{page.path}}" role="button" target="_blank">
{% endif -%}
<img class="notebook-badge-image" src="{{ "assets/badges/github.svg" | relative_url }}" alt="View On GitHub">
</a>
Expand Down
4 changes: 2 additions & 2 deletions _includes/youtube.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
{% assign url = include.content | remove: "</a>" | split: ">" | last %}
{% assign base_url = url | split: "/" | last %}
{% endif %}
<center>
<iframe width="560" height="315" src="https://www.youtube.com/embed/{{base_url}}" frameborder="0" allowfullscreen></iframe>
<center class="youtube-iframe-wrapper">
<iframe width="730" height="315" src="https://www.youtube.com/embed/{{base_url}}" frameborder="0" allowfullscreen></iframe>
</center>
18 changes: 18 additions & 0 deletions _sass/minima/fastpages-styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -256,3 +256,21 @@ table {
pre code {
font-size: 15px !important;
}

// Handle youtube videos, so they dont break on mobile devices
.youtube-iframe-wrapper {
position: relative;
padding-bottom: 56.10%;
height: 0;
overflow: hidden;
}

.youtube-iframe-wrapper iframe,
.youtube-iframe-wrapper object,
.youtube-iframe-wrapper embed {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
}

0 comments on commit 67f6c90

Please sign in to comment.