Skip to content

Commit ed3af15

Browse files
authored
Added SiteDiff to development environment (#72)
- Added Docker service for SiteDiff - Added configuration for SiteDiff to dedicated `dev` directory - Moved `Dockerfile` for Jekyll service to dedicated `dev` directory - Added BPKG commands for SiteDiff processes - Updated GIT ignore to handle SiteDiff runtime files - Updated README for SiteDiff processes - Updated README for missing LESSC command
1 parent 22541d3 commit ed3af15

File tree

6 files changed

+180
-20
lines changed

6 files changed

+180
-20
lines changed

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ _site/*
55
_theme_packages/*
66
.jekyll-cache/*
77

8+
/dev/sitediff/*
9+
!/dev/sitediff/config.yaml
10+
811
Thumbs.db
912
.DS_Store
1013

README.md

+73-19
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# bpkg.github.io
1+
# bpkg.github.io (bpkg.sh)
22

33
`bpkg` is a lightweight bash package manager.
44
This repository contains the source code of it's homepage.
@@ -23,28 +23,37 @@ In the remainder of this document, if there is a accompanying `bpkg` _command_ i
2323
2424
## Docker Environment
2525

26-
This environment is not necessary to use if you'd rather run everything directly on your host system. This environment is provided however, to facilitate all the required components for building and development of `bpkg` site. There are associated `bpkg` commands to interact with the Docker environment.
26+
This environment is not necessary to use if you'd rather run everything directly on your host system. This environment is provided however, to facilitate all the required components for building and development of `bpkg` site.
27+
28+
A `docker-composer.yml` file exists in the root directory of the project to specify the Docker services
29+
30+
* `jekyll` – Perform Jekyll and Rake processes
31+
> **NOTE:** _A custom `Dockerfile` exists to generate the image for this service, in the `dev/jekyll` directory_
32+
* `lessc` – Implements LESS preprocessing
33+
* `sitediff` – Host SiteDiff for performing site comparison
34+
35+
There are associated `bpkg` commands to interact with the Docker environments, accompanying Docker commands will be listed like the other `bpkg` commands.
2736

2837
## Dependencies
2938

3039
This website was made with the [Jekyll][jekyll] engine, so it depends on a few
31-
Ruby Gems. To install them, run the following command.
40+
Ruby Gems. To install them, run the following command:
3241

3342
```bash
3443
$ gem install jekyll
3544
```
3645

3746
It might take a while to finish, but once it does you're ready to go.
3847

39-
## How to edit
48+
## Edit Site Pages
4049

4150
To **make changes** to the page or **run it locally**, clone this GitHub
4251
repository and make sure you have _installed the dependencies_ above.
4352

4453
Then, it's a matter of editing pages and running `rake` tasks. Here's a rundown
45-
of possible commands (thanks to [this great quickstart on Jekyll][tuto]):
54+
of possible commands (thanks to [this great quickstart on Jekyll][tuto]).
4655

47-
---
56+
### Preview Site
4857

4958
```bash
5059
$ rake preview
@@ -56,12 +65,12 @@ $ rake preview
5665
Builds the entire site to a local folder `_site` and launches a webserver to
5766
preview it.
5867

59-
To see the full site, point your browser to `localhost:4000`.
68+
To see the full site, point your browser to [`localhost:4000`][preview-url].
6069

6170
If you make any changes on any files, it will regenerate the website
6271
automatically.
6372

64-
---
73+
### Create Post
6574

6675
```bash
6776
$ rake post title="Hello, World!"
@@ -76,7 +85,7 @@ the date is the current, by default.
7685
No further changes are required, the post will get automatically inserted on the
7786
site.
7887

79-
---
88+
### Create Page
8089

8190
```bash
8291
$ rake page name="about"
@@ -96,6 +105,47 @@ $ rake page name="about.html"
96105
97106
Alternative way to create a new page, on this case it will be `./about.html`.
98107

108+
## Update Style Sheets
109+
110+
This project uses [LESS (Leaner Style Sheets)][less] files to generate the CSS for this site. When modifying the site style sheets under the `/assets` directory, update the LESS files (ie: `*.less`). To update the CSS file after making changes to any of the LESS files, run the following command (from the root of the project):
111+
112+
```bash
113+
$ lessc ./assets/themes/the-program/css/style.less ./assets/themes/the-program/css/style.css
114+
```
115+
116+
> **BPKG:** `lessc`<br />
117+
> **BPKG:** `docker-lessc`
118+
119+
## View Site Changes
120+
121+
When working on the site, sometimes it's helpful to see changes between the production copy and the output of local changes. A report of changes can be generated with the [SiteDiff][sitediff] tool, to simplify this process a Docker service has been included with a few `bpkg` commands. This is a multi-step process (each step has an associated 'bpkg' command), but a single command can be used to run all the steps. Before performing these steps the local version needs to be in [preview mode](#preview-site).
122+
123+
### SiteDiff - Crawl Sites
124+
125+
The SiteDiff utility will crawl the production and the preview versions of the site prior to performing the comparison:
126+
127+
> **BPKG:** `site-crawl`
128+
129+
### SiteDiff - Diff Crawled Sites
130+
131+
After crawling the versions of the sites, SiteDiff will compare the preview against the production version and generate a change report:
132+
133+
> **BPKG:** `site-diff`
134+
135+
### SiteDiff - Serve Report
136+
137+
The generated report can be served for viewing by SiteDiff:
138+
139+
> **BPKG:** `site-serve`
140+
141+
To see the report, point your browser to [`localhost:13080`][report-url].
142+
143+
### SiteDiff
144+
145+
The preceding command performs the following steps (which can be run individually):
146+
147+
> **BPKG:** `sitediff`
148+
99149
## Notes
100150

101151
* When producing content (writing pages/posts) keep in mind
@@ -111,13 +161,17 @@ Alternative way to create a new page, on this case it will be `./about.html`.
111161
This site uses [Jekyll Bootstrap][boots] with a heavily customized version of
112162
[the_program][theme] theme, originally made by [Yuya Saito][saito].
113163

114-
[home]: https://bpkg.sh/
115-
[hub]: https://github.com/bpkg/bpkg
116-
[org]: https://github.com/bpkg
117-
[jekyll]: https://jekyllrb.com/
118-
[tuto]: http://jekyllbootstrap.com/usage/jekyll-quick-start.html
119-
[posts]: https://jekyllrb.com/docs/posts/
120-
[intro]: http://jekyllbootstrap.com/lessons/jekyll-introduction.html
121-
[boots]: http://jekyllbootstrap.com/
122-
[theme]: https://github.com/jekyllbootstrap/theme-the-program
123-
[saito]: https://studiomohawk.com/
164+
[home]: https://bpkg.sh/
165+
[hub]: https://github.com/bpkg/bpkg
166+
[org]: https://github.com/bpkg/
167+
[jekyll]: https://jekyllrb.com/
168+
[tuto]: http://jekyllbootstrap.com/usage/jekyll-quick-start.html
169+
[preview-url]: http://localhost:4000/
170+
[less]: https://lesscss.org/
171+
[sitediff]: http://sitediff.io/
172+
[report-url]: http://localhost:13080/
173+
[posts]: https://jekyllrb.com/docs/posts/
174+
[intro]: http://jekyllbootstrap.com/lessons/jekyll-introduction.html
175+
[boots]: http://jekyllbootstrap.com/
176+
[theme]: https://github.com/jekyllbootstrap/theme-the-program/
177+
[saito]: https://studiomohawk.com/

bpkg.json

+5
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@
1010
"page": "rake page $@",
1111
"lessc": "lessc ./assets/themes/the-program/css/style.less ./assets/themes/the-program/css/style.css",
1212

13+
"site-crawl": "docker-compose run --rm --service-ports sitediff crawl --directory=./ ./config.yaml",
14+
"site-diff": "docker-compose run --rm --service-ports sitediff diff --directory=./ ./config.yaml",
15+
"site-serve": "docker-compose run --rm --service-ports sitediff serve --directory=./ ./config.yaml",
16+
"sitediff": "bpkg run site-crawl; bpkg run site-diff; bpkg run site-serve",
17+
1318
"docker": "docker-compose run --rm --service-ports jekyll $@",
1419

1520
"docker-shell": "bpkg run docker /bin/bash",
File renamed without changes.

dev/sitediff/config.yaml

+85
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
## Documentation:
2+
## https://github.com/evolvingweb/sitediff
3+
4+
## Include other configuration files, merging them with this file.
5+
includes:
6+
# - extra-rules.yaml
7+
8+
## Settings.
9+
##
10+
## If you use "sitediff init" with the right parameters, it will generate
11+
## this section for you.
12+
settings:
13+
## Crawl 4 levels deep.
14+
depth: 4
15+
16+
## Wait for 250ms between requests.
17+
# interval: 250
18+
19+
## Make only 1 request at a time - no simultaneous requests.
20+
## Concurrency has to be one when an interval is set.
21+
# concurrency: 1
22+
23+
## Don't follow links to XML files.
24+
exclude: !ruby/regexp /^\/feed\//
25+
26+
## Curl options, if any.
27+
curl_opts:
28+
# max_recv_speed_large: 10000
29+
30+
## Rules under this element apply only to the 'before' site.
31+
before:
32+
## URL of the 'before' version of the site.
33+
url: https://bpkg.sh
34+
35+
## Sanitizations and DOM transformations, just like the general ones
36+
## demonstrated below, but applied only to the 'before' site.
37+
sanitization:
38+
- title: Remove Google analytics script (added in production)
39+
pattern: !ruby/regexp /\n[ \t]*<script[^<]+\.google-analytics\.com\/ga\.js[^<]+<\/script>[ \t]*/
40+
41+
dom_transform:
42+
43+
## Rules under this element apply only to the 'after' site.
44+
after:
45+
## URL of the 'after' version of the site.
46+
url: http://host.docker.internal:4000
47+
48+
## Sanitizations and DOM transformations, just like the general ones
49+
## demonstrated below, but applied only to the 'after' site.
50+
sanitization:
51+
- title: Remove JavaScript development variable (added in development)
52+
pattern: !ruby/regexp /\n[ \t]*var disqus_developer = 1;/
53+
54+
dom_transform:
55+
56+
## The root element to compare.
57+
##
58+
## Usually, sitediff compares the HTML of the entire page. If you'd rather
59+
## check just a subset of the page, specify a selector here. For example, the
60+
## line below causes only the body to be compared, ignoring the HTML head.
61+
# selector: 'body'
62+
63+
## Ignore whitespace when doing the diff.
64+
# ignore_whitespace: true
65+
66+
## General regular expression rules, applied to both versions of the site.
67+
sanitization:
68+
- title: Remove timezone offset from publish date-time (can differ from local and production)
69+
selector: date.date-pub
70+
pattern: !ruby/regexp /(\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}).\d{2}:\d{2}/
71+
substitute: '\1_TZ_OFFSET_'
72+
73+
## General DOM transforms, applied to both versions of the site.
74+
dom_transform:
75+
76+
## Report settings allow you to display helpful details on the report.
77+
report:
78+
title: BPKG Packages Site - for the bpkg project
79+
details: This report outlines visual differences between the published (production) version and the locally generated version.
80+
before_note: Production Site
81+
after_note: Locally Generated
82+
# before_url_report: https://bpkg.sh
83+
# after_url_report: http://localhost:13080/cache/after
84+
# before_url_report: false
85+
after_url_report: http://localhost:4000

docker-compose.yml

+14-1
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,27 @@ version: "3"
33
services:
44
jekyll:
55
build:
6-
context: ./dev/
6+
context: ./dev/jekyll/
77
volumes:
88
- ./:/srv/jekyll:Z
99
ports:
1010
- "4000:4000"
1111
stdin_open: true
1212
tty: true
13+
1314
lessc:
1415
image: finalgene/lessc
1516
volumes:
1617
- ./:/app
18+
19+
sitediff:
20+
image: evolvingweb/sitediff
21+
volumes:
22+
- ./dev/sitediff:/sitediff
23+
# network_mode: host
24+
ports:
25+
- "13080:13080"
26+
stdin_open: true
27+
tty: true
28+
entrypoint: sitediff
29+
command: help

0 commit comments

Comments
 (0)