Skip to content

Commit

Permalink
Improve code style
Browse files Browse the repository at this point in the history
- js/css
- markdown
- shell
  • Loading branch information
cotes2020 committed Jan 27, 2021
1 parent d8a42d9 commit 8e84c6b
Show file tree
Hide file tree
Showing 14 changed files with 1,052 additions and 1,008 deletions.
55 changes: 25 additions & 30 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ Follow the [Jekyll Docs](https://jekyllrb.com/docs/installation/) to complete th

There are two ways to get the theme:

- Install from [RubyGems](https://rubygems.org/gems/jekyll-theme-chirpy)
- Fork from GitHub
- Install from [RubyGems](https://rubygems.org/gems/jekyll-theme-chirpy)
- Fork from GitHub

### Install From Rubygems

Expand Down Expand Up @@ -81,9 +81,6 @@ $ bundle info --path jekyll-theme-chirpy

Or you can [use the starter template][use-starter] to create a Jekyll site to save time copying contents from theme's gem.

[starter]: https://github.com/cotes2020/chirpy-starter
[use-starter]: https://github.com/cotes2020/chirpy-starter/generate

### Fork From GitHub

[Fork **Chirpy**](https://github.com/cotes2020/jekyll-theme-chirpy/fork) from GitHub and clone your fork to local.
Expand All @@ -104,27 +101,26 @@ $ bash tools/init.sh
What it does is:

1. Remove some files or directories from your repository:

- `.travis.yml`
- files under `_posts`
- folder `docs`
1. Remove some files or directories from your repository:

2. If you use the `--no-gh` option, the directory `.github` will be deleted. Otherwise, setup the GitHub Action workflow by removing extension `.hook` of `.github/workflows/pages-deploy.yml.hook`, and then remove the other files and directories in folder `.github`.
- `.travis.yml`
- files under `_posts`
- folder `docs`

3. Automatically create a commit to save the changes.
2. If you use the `--no-gh` option, the directory `.github` will be deleted. Otherwise, setup the GitHub Action workflow by removing extension `.hook` of `.github/workflows/pages-deploy.yml.hook`, and then remove the other files and directories in folder `.github`.

3. Automatically create a commit to save the changes.

## Usage

### Configuration

Update the variables of `_config.yml` as needed. Some of them are typical options:

- `url`
- `avatar`
- `timezone`
- `theme_mode`
- `url`
- `avatar`
- `timezone`
- `theme_mode`

### Running Local Server

Expand Down Expand Up @@ -157,23 +153,20 @@ For security reasons, GitHub Pages build runs on `safe` mode, which restricts us

Quickly check the files needed for GitHub Actions build:

1. Ensure your Jekyll site has the file `/.github/workflows/pages-deploy.yml`. Otherwise, create a new one and fill in the contents of the [workflow file][workflow], and the value of the `on.push.branches` should be the same as your repo's default branch name.

2. Ensuer your Jekyll site has file `/tools/test.sh` and `/tools/deploy.sh`. Otherwise, copy them from this repo to your Jekyll site.

[workflow]:https://github.com/cotes2020/jekyll-theme-chirpy/blob/master/.github/workflows/pages-deploy.yml.hook
1. Ensure your Jekyll site has the file `/.github/workflows/pages-deploy.yml`. Otherwise, create a new one and fill in the contents of the [workflow file][workflow], and the value of the `on.push.branches` should be the same as your repo's default branch name.
2. Ensuer your Jekyll site has file `/tools/test.sh` and `/tools/deploy.sh`. Otherwise, copy them from this repo to your Jekyll site.

Next, rename your repoistory to `<GH-USERNAME>.github.io` on GitHub.

And then publish your Jekyll site by:

1. Push any commit to remote to trigger the GitHub Actions workflow. Once the build is complete and successful, a new remote branch named `gh-pages` will appear to store the built site files.
1. Push any commit to remote to trigger the GitHub Actions workflow. Once the build is complete and successful, a new remote branch named `gh-pages` will appear to store the built site files.

2. Browse to your repo's landing page on GitHub and select the branch `gh-pages` as the [publishing source](https://docs.github.com/en/github/working-with-github-pages/configuring-a-publishing-source-for-your-github-pages-site) throught _Settings__Options__GitHub Pages_:
2. Browse to your repo's landing page on GitHub and select the branch `gh-pages` as the [publishing source](https://docs.github.com/en/github/working-with-github-pages/configuring-a-publishing-source-for-your-github-pages-site) throught _Settings__Options__GitHub Pages_:

![gh-pages-sources](https://cdn.jsdelivr.net/gh/cotes2020/chirpy-images/posts/20190809/gh-pages-sources.png)
![gh-pages-sources](https://cdn.jsdelivr.net/gh/cotes2020/chirpy-images/posts/20190809/gh-pages-sources.png)

3. Visit your website at the address indicated by GitHub.
3. Visit your website at the address indicated by GitHub.

#### Deploy on Other Platforms

Expand All @@ -197,7 +190,6 @@ $ docker run -it --rm \

Unless you specified the output path, the generated site files will be placed in folder `_site` of the project's root directory. Now you should upload those files to your web server.


## Documentation

For more details and the better reading experience, please check out the [tutorials on demo site](https://chirpy.cotes.info/categories/tutorial/). In the meanwhile, a copy of the tutorial is also available on the [Wiki](https://github.com/cotes2020/jekyll-theme-chirpy/wiki).
Expand All @@ -212,11 +204,9 @@ This theme is mainly built with [Jekyll](https://jekyllrb.com/) ecosystem, [Boot

:tada: Thanks to all the volunteers who contributed to this project, their GitHub IDs are on [this list](https://github.com/cotes2020/jekyll-theme-chirpy/graphs/contributors). Also, I won't forget those guys who submitted the issues or unmerged PR because they reported bugs, shared ideas or inspired me to write more readable documentation.

Also, thank [JetBrains][JB] for providing the open source license.

[![JB-logo](https://cdn.jsdelivr.net/gh/cotes2020/chirpy-images/commons/jetbrains.svg)][JB]
Also, thank [JetBrains][jb] for providing the open source license.

[JB]:https://www.jetbrains.com/?from=jekyll-theme-chirpy
[![JB-logo](https://cdn.jsdelivr.net/gh/cotes2020/chirpy-images/commons/jetbrains.svg)][jb]

## Supporting

Expand All @@ -225,3 +215,8 @@ If you enjoy this theme or find it helpful, please consider becoming my sponsor,
## License

This work is published under [MIT](https://github.com/cotes2020/jekyll-theme-chirpy/blob/master/LICENSE) License.

[starter]: https://github.com/cotes2020/chirpy-starter
[use-starter]: https://github.com/cotes2020/chirpy-starter/generate
[workflow]:https://github.com/cotes2020/jekyll-theme-chirpy/blob/master/.github/workflows/pages-deploy.yml.hook
[jb]:https://www.jetbrains.com/?from=jekyll-theme-chirpy
42 changes: 18 additions & 24 deletions _posts/2019-08-09-getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ Follow the [Jekyll Docs](https://jekyllrb.com/docs/installation/) to complete th

There are two ways to get the theme:

- Install from [RubyGems](https://rubygems.org/gems/jekyll-theme-chirpy)
- Fork from GitHub
- Install from [RubyGems](https://rubygems.org/gems/jekyll-theme-chirpy)
- Fork from GitHub

### Install From Rubygems

Expand Down Expand Up @@ -48,9 +48,6 @@ $ bundle info --path jekyll-theme-chirpy

Or you can [use the starter template][use-starter] to create a Jekyll site to save time copying contents from theme's gem.

[starter]: https://github.com/cotes2020/chirpy-starter
[use-starter]: https://github.com/cotes2020/chirpy-starter/generate

### Fork From GitHub

[Fork **Chirpy**](https://github.com/cotes2020/jekyll-theme-chirpy/fork) from GitHub and clone your fork to local.
Expand All @@ -71,15 +68,15 @@ $ bash tools/init.sh
What it does is:

1. Remove some files or directories from your repository:
1. Remove some files or directories from your repository:

- `.travis.yml`
- files under `_posts`
- folder `docs`
- `.travis.yml`
- files under `_posts`
- folder `docs`

2. If you use the `--no-gh` option, the directory `.github` will be deleted. Otherwise, setup the GitHub Action workflow by removing extension `.hook` of `.github/workflows/pages-deploy.yml.hook`, and then remove the other files and directories in folder `.github`.
2. If you use the `--no-gh` option, the directory `.github` will be deleted. Otherwise, setup the GitHub Action workflow by removing extension `.hook` of `.github/workflows/pages-deploy.yml.hook`, and then remove the other files and directories in folder `.github`.

3. Automatically create a commit to save the changes.
3. Automatically create a commit to save the changes.


## Usage
Expand All @@ -88,10 +85,10 @@ What it does is:

Update the variables of `_config.yml` as needed. Some of them are typical options:

- `url`
- `avatar`
- `timezone`
- `theme_mode`
- `url`
- `avatar`
- `timezone`
- `theme_mode`

### Running Local Server

Expand Down Expand Up @@ -124,23 +121,20 @@ For security reasons, GitHub Pages build runs on `safe` mode, which restricts us

Quickly check the files needed for GitHub Actions build:

1. Ensure your Jekyll site has the file `/.github/workflows/pages-deploy.yml`. Otherwise, create a new one and fill in the contents of the [workflow file][workflow], and the value of the `on.push.branches` should be the same as your repo's default branch name.

2. Ensuer your Jekyll site has file `/tools/test.sh` and `/tools/deploy.sh`. Otherwise, copy them from this repo to your Jekyll site.

[workflow]:https://github.com/cotes2020/jekyll-theme-chirpy/blob/master/.github/workflows/pages-deploy.yml.hook
1. Ensure your Jekyll site has the file `/.github/workflows/pages-deploy.yml`. Otherwise, create a new one and fill in the contents of the [workflow file][workflow], and the value of the `on.push.branches` should be the same as your repo's default branch name.
2. Ensuer your Jekyll site has file `/tools/test.sh` and `/tools/deploy.sh`. Otherwise, copy them from this repo to your Jekyll site.

Next, rename your repoistory to `<GH-USERNAME>.github.io` on GitHub.

And then publish your Jekyll site by:

1. Push any commit to remote to trigger the GitHub Actions workflow. Once the build is complete and successful, a new remote branch named `gh-pages` will appear to store the built site files.
1. Push any commit to remote to trigger the GitHub Actions workflow. Once the build is complete and successful, a new remote branch named `gh-pages` will appear to store the built site files.

2. Browse to your repo's landing page on GitHub and select the branch `gh-pages` as the [publishing source](https://docs.github.com/en/github/working-with-github-pages/configuring-a-publishing-source-for-your-github-pages-site) throught _Settings__Options__GitHub Pages_:
2. Browse to your repo's landing page on GitHub and select the branch `gh-pages` as the [publishing source](https://docs.github.com/en/github/working-with-github-pages/configuring-a-publishing-source-for-your-github-pages-site) throught _Settings__Options__GitHub Pages_:

![gh-pages-sources](https://cdn.jsdelivr.net/gh/cotes2020/chirpy-images/posts/20190809/gh-pages-sources.png)
![gh-pages-sources](https://cdn.jsdelivr.net/gh/cotes2020/chirpy-images/posts/20190809/gh-pages-sources.png)

3. Visit your website at the address indicated by GitHub.
3. Visit your website at the address indicated by GitHub.

#### Deploy on Other Platforms

Expand Down
34 changes: 17 additions & 17 deletions _posts/2021-01-03-enable-google-pv.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ This post is to enable Page Views on the [**Chirpy**][chirpy-homepage] theme bas
First, you need to setup your account on Google analytics. While your create your account, you must create your first **Property** as well.

1. Head to <https://analytics.google.com/> and click on **Start Measuring**
2. Enter your desired *Account Name* and choose the desired checkboxes
3. Enter your desired *Property Name*. This is the name of the tracker project that appears on your Google Analytics dashboard
4. Enter the required information *About your business*
5. Hit *Create* and accept any license popup to setup your Google Analytics account and create your property
2. Enter your desired _Account Name_ and choose the desired checkboxes
3. Enter your desired _Property Name_. This is the name of the tracker project that appears on your Google Analytics dashboard
4. Enter the required information _About your business_
5. Hit _Create_ and accept any license popup to setup your Google Analytics account and create your property

### Create Data Stream

Expand Down Expand Up @@ -75,9 +75,9 @@ There is a detailed [tutorial](https://developers.google.com/analytics/solutions
8. Click on **Enable APIs and Services** button on the top
9. Enable the following APIs: *Google Analytics API*
9. Enable the following APIs: _Google Analytics API_
10. On the left, Click on *OAuth Consent Screen* and accept **Configure Consent Screen**. Select **External** since your blog is probably hosted for the public. Click on **Publish** under *Publishing Status*
10. On the left, Click on _OAuth Consent Screen_ and accept **Configure Consent Screen**. Select **External** since your blog is probably hosted for the public. Click on **Publish** under _Publishing Status_
11. Click on **Credentials** on the left and create a new **OAuth Client IDs** credential. Make sure to add a entry under `Authorized redirect URIs` that matches: `https://<project-id>.<region>.r.appspot.com/admin/auth`

Expand Down Expand Up @@ -116,10 +116,11 @@ There is a detailed [tutorial](https://developers.google.com/analytics/solutions
1. Clone the **Google Analytics superProxy** project on Github: <https://github.com/googleanalytics/google-analytics-super-proxy> to your local.

2. Remove the first 2 lines in the [`src/app.yaml`](https://github.com/googleanalytics/google-analytics-super-proxy/blob/master/src/app.yaml#L1-L2) file:
```diff
- application: your-project-id
- version: 1
```

```yaml
-application: your-project-id
-version: 1
```

3. In `src/config.py`, add the `OAUTH_CLIENT_ID` and `OAUTH_CLIENT_SECRET` that you gathered from you App Engine Dashboard.

Expand All @@ -143,7 +144,8 @@ There is a detailed [tutorial](https://developers.google.com/analytics/solutions
# XSRF Settings
XSRF_KEY = 'OnceUponATimeThereLivedALegend'
```
**Tip:** You can configure a custom domain instead of `https://PROJECT_ID.REGION_ID.r.appspot.com`. But, for the sake of keeping it simple, we will be using the Google provided default URL.

**Tip:** You can configure a custom domain instead of `https://PROJECT_ID.REGION_ID.r.appspot.com`. But, for the sake of keeping it simple, we will be using the Google provided default URL.

5. From inside the src/ directory, deploy the app

Expand Down Expand Up @@ -194,20 +196,17 @@ Head to `https://PROJECT_ID.REGION_ID.r.appspot.com/admin` and create a query af
The query parameters are as follows:

- **start-date**: fill in the first day of blog posting

- **end-date**: fill in `today` (this is a parameter supported by GA Report, which means that it will always end according to the current query date)

- **metrics**: select `ga:pageviews`

- **dimensions**: select `ga:pagePath`

In order to reduce the returned results and reduce the network bandwidth, we add custom filtering rules [^ga-filters]:

- **filters**: fill in `ga:pagePath=~^/posts/.*/$;ga:pagePath!@=`
- **filters**: fill in `ga:pagePath=~^/posts/.*/$;ga:pagePath!@=`.

Among them, `;` means using _logical AND_ to concatenate two rules.
Among them, `;` means using _logical AND_ to concatenate two rules.

If the `site.baseurl` is specified, change the first filtering rule to `ga:pagePath=~^/BASE_URL/posts/.*/$`, where `BASE_URL` is the value of `site.baseurl`.
If the `site.baseurl` is specified, change the first filtering rule to `ga:pagePath=~^/BASE_URL/posts/.*/$`, where `BASE_URL` is the value of `site.baseurl`.

After <kbd>Run Query</kbd>, copy the generated contents of **API Query URI** at the bottom of the page, and fill in the **Encoded URI for the query** of SuperProxy on GAE.

Expand All @@ -224,6 +223,7 @@ Once all the hard part is done, it is very easy to enable the Page View on Chirp

Update the `_config.yml` file of [**Chirpy**][chirpy-homepage] project with the values from your dashboard, to look similar to the following:


```yaml
google_analytics:
id: 'G-XXXXXXXXXX' # Fill with your Google Analytics ID
Expand Down
Loading

0 comments on commit 8e84c6b

Please sign in to comment.