Skip to content

Commit 6feea30

Browse files
iBugminyoongi96
authored andcommittedAug 26, 2024
Consolidate hard-coded version numbers where possible
Now only 4 files left untouchable. Search README.md for "Dev note" for details.
1 parent 4386fbd commit 6feea30

14 files changed

+106
-56
lines changed
 

‎README.md

+24-8
Original file line numberDiff line numberDiff line change
@@ -115,22 +115,42 @@ To install:
115115

116116
2. Add `jekyll-include-cache` to the `plugins` array of your `_config.yml`.
117117

118-
3. Fetch and update bundled gems by running the following [Bundler](http://bundler.io/) command:
118+
3. Fetch and update bundled gems by running the following [Bundler](https://bundler.io/) command:
119119

120120
```bash
121121
bundle
122122
```
123123

124124
4. Add `remote_theme: "mmistakes/minimal-mistakes@4.24.0"` to your `_config.yml` file. Remove any other `theme:` or `remote_theme:` entry.
125125

126+
<!--
127+
Dev note: The version number is currently hard-coded in these files:
128+
129+
- README.md (this file)
130+
- package.json
131+
- docs/_config.yml (as theme_version)
132+
- docs/_pages/home.md (in Front Matter "excerpt")
133+
134+
For every release, files listed above should be manually updated with the new version number.
135+
136+
Additionally, the license year is hard-coded in these files:
137+
138+
- README.md (this file, near the end)
139+
- LICENSE
140+
141+
The following files should also be regenerated:
142+
143+
- _includes/copyright.html, _includes/copyright.js, _sass/minimal-mistakes/_copyright.scss
144+
(Run `bundle exec rake clean` then `bundle exec rake copyright` - all three references `package.json`)
145+
- assets/js/main.min.js (Run `npm run build:js`, references `_includes/copyright.js`)
146+
-->
147+
126148
**Looking for an example?** Use the [Minimal Mistakes remote theme starter](https://github.com/mmistakes/mm-github-pages-starter/generate) for the quickest method of getting a GitHub Pages hosted site up and running. Generate a new repository from the starter, replace sample content with your own, and configure as needed.
127149

128150
## Usage
129151

130152
For detailed instructions on how to configure, customize, add/migrate content, and more read the [theme's documentation](https://mmistakes.github.io/minimal-mistakes/docs/quick-start-guide/).
131153

132-
---
133-
134154
## Contributing
135155

136156
Found a typo in the documentation or interested in [fixing a bug](https://github.com/mmistakes/minimal-mistakes/issues)? Then by all means [submit an issue](https://github.com/mmistakes/minimal-mistakes/issues/new) or [pull request](https://help.github.com/articles/using-pull-requests/). If this is your first pull request, it may be helpful to read up on the [GitHub Flow](https://guides.github.com/introduction/flow/) first.
@@ -153,8 +173,6 @@ To set up your environment to develop this theme, run `bundle install`.
153173

154174
To test the theme, run `bundle exec rake preview` and open your browser at `http://localhost:4000/test/`. This starts a Jekyll server using content in the `test/` directory. As modifications are made to the theme and test site, it will regenerate and you should see the changes in the browser after a refresh.
155175

156-
---
157-
158176
## Credits
159177

160178
### Creator
@@ -167,7 +185,7 @@ To test the theme, run `bundle exec rake preview` and open your browser at `http
167185

168186
### Icons + Demo Images:
169187

170-
- [The Noun Project](https://thenounproject.com) -- Garrett Knoll, Arthur Shlain, and [tracy tam](https://thenounproject.com/tracytam)
188+
- [The Noun Project](https://thenounproject.com) - Garrett Knoll, Arthur Shlain, and [tracy tam](https://thenounproject.com/tracytam)
171189
- [Font Awesome](http://fontawesome.io/)
172190
- [Unsplash](https://unsplash.com/)
173191

@@ -185,8 +203,6 @@ To test the theme, run `bundle exec rake preview` and open your browser at `http
185203
- [jQuery throttle / debounce](http://benalman.com/projects/jquery-throttle-debounce-plugin/)
186204
- [Lunr](http://lunrjs.com)
187205

188-
---
189-
190206
## License
191207

192208
The MIT License (MIT)

‎Rakefile

+43
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
require "bundler/gem_tasks"
22
require "jekyll"
3+
require "json"
34
require "listen"
5+
require "rake/clean"
46
require "time"
57
require "yaml"
68

9+
package_json = JSON.parse(File.read("package.json"))
10+
711
def listen_ignore_paths(base, options)
812
[
913
/_config\.ya?ml/,
@@ -101,3 +105,42 @@ file "docs/_docs/18-history.md" => "CHANGELOG.md" do |t|
101105
f.puts "{% endraw %}"
102106
end
103107
end
108+
109+
COPYRIGHT_LINES = [
110+
"Minimal Mistakes Jekyll Theme #{package_json["version"]} by Michael Rose",
111+
"Copyright 2013-2020 Michael Rose - mademistakes.com | @mmistakes",
112+
"Free for personal and commercial use under the MIT license",
113+
"https://github.com/mmistakes/minimal-mistakes/blob/master/LICENSE",
114+
]
115+
116+
COPYRIGHT_FILES = [
117+
"_includes/copyright.html",
118+
"_includes/copyright.js",
119+
"_sass/minimal-mistakes/_copyright.scss",
120+
]
121+
122+
def genenerate_copyright_file(filename, header, prefix, footer)
123+
File.open(filename, "w") do |f|
124+
f.puts header
125+
COPYRIGHT_LINES.each do |line|
126+
f.puts "#{prefix}#{line}"
127+
end
128+
f.puts footer
129+
end
130+
end
131+
132+
file "_includes/copyright.html" do |t|
133+
genenerate_copyright_file(t.name, "<!--", " ", "-->")
134+
end
135+
136+
file "_includes/copyright.js" do |t|
137+
genenerate_copyright_file(t.name, "/*!", " * ", " */")
138+
end
139+
140+
file "_sass/minimal-mistakes/_copyright.scss" do |t|
141+
genenerate_copyright_file(t.name, "/*!", " * ", " */")
142+
end
143+
144+
task :copyright => COPYRIGHT_FILES
145+
146+
CLEAN.include(*COPYRIGHT_FILES)

‎_includes/copyright.html

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<!--
2+
Minimal Mistakes Jekyll Theme 4.24.0 by Michael Rose
3+
Copyright 2013-2020 Michael Rose - mademistakes.com | @mmistakes
4+
Free for personal and commercial use under the MIT license
5+
https://github.com/mmistakes/minimal-mistakes/blob/master/LICENSE
6+
-->

‎_includes/copyright.js

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
/*!
2+
* Minimal Mistakes Jekyll Theme 4.24.0 by Michael Rose
3+
* Copyright 2013-2020 Michael Rose - mademistakes.com | @mmistakes
4+
* Free for personal and commercial use under the MIT license
5+
* https://github.com/mmistakes/minimal-mistakes/blob/master/LICENSE
6+
*/

‎_layouts/default.html

+1-6
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,7 @@
22
---
33

44
<!doctype html>
5-
<!--
6-
Minimal Mistakes Jekyll Theme 4.24.0 by Michael Rose
7-
Copyright 2013-2020 Michael Rose - mademistakes.com | @mmistakes
8-
Free for personal and commercial use under the MIT license
9-
https://github.com/mmistakes/minimal-mistakes/blob/master/LICENSE
10-
-->
5+
{% include "copyright.html" %}
116
<html lang="{{ site.locale | slice: 0,2 | default: "en" }}" class="no-js">
127
<head>
138
{% include head.html %}

‎_sass/minimal-mistakes.scss

+2-5
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
1-
/*!
2-
* Minimal Mistakes Jekyll Theme 4.24.0 by Michael Rose
3-
* Copyright 2013-2020 Michael Rose - mademistakes.com | @mmistakes
4-
* Licensed under MIT (https://github.com/mmistakes/minimal-mistakes/blob/master/LICENSE)
5-
*/
1+
/* Copyright comment */
2+
@import "minimal-mistakes/copyright";
63

74
/* Variables */
85
@import "minimal-mistakes/variables";
+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
/*!
2+
* Minimal Mistakes Jekyll Theme 4.24.0 by Michael Rose
3+
* Copyright 2013-2020 Michael Rose - mademistakes.com | @mmistakes
4+
* Free for personal and commercial use under the MIT license
5+
* https://github.com/mmistakes/minimal-mistakes/blob/master/LICENSE
6+
*/

‎banner.js

+3-15
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,7 @@
11
const fs = require("fs");
2-
const pkg = require("./package.json");
3-
const filename = "assets/js/main.min.js";
4-
const script = fs.readFileSync(filename);
5-
const padStart = str => ("0" + str).slice(-2);
6-
const dateObj = new Date();
7-
const date = `${dateObj.getFullYear()}-${padStart(
8-
dateObj.getMonth() + 1
9-
)}-${padStart(dateObj.getDate())}`;
10-
const banner = `/*!
11-
* Minimal Mistakes Jekyll Theme ${pkg.version} by ${pkg.author}
12-
* Copyright 2013-${dateObj.getFullYear()} Michael Rose - mademistakes.com | @mmistakes
13-
* Licensed under ${pkg.license}
14-
*/
15-
`;
2+
const script = fs.readFileSync("assets/js/main.min.js");
3+
const banner = fs.readFileSync("_includes/copyright.js");
164

17-
if (script.slice(0, 3) != "/**") {
5+
if (script.slice(0, 3) != "/*!") {
186
fs.writeFileSync(filename, banner + script);
197
}

‎docs/_config.yml

+2-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
# For technical reasons, this file is *NOT* reloaded automatically when you use
66
# `jekyll serve`. If you change this file, please restart the server process.
77

8-
remote_theme : "mmistakes/minimal-mistakes@4.24.0"
8+
remote_theme : "mmistakes/minimal-mistakes@master"
9+
theme_version : "4.24.0"
910

1011
minimal_mistakes_skin : "default" # "air", "aqua", "contrast", "dark", "dirt", "neon", "mint", "plum", "sunrise"
1112

‎docs/_docs/01-quick-start-guide.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ To install as a remote theme:
7878
bundle
7979
```
8080

81-
4. Add `remote_theme: "mmistakes/minimal-mistakes@4.24.0"` to your `_config.yml` file. Remove any other `theme:` or `remote_theme:` entry.
81+
4. Add `remote_theme: "mmistakes/minimal-mistakes@{{ site.theme_version }}"` to your `_config.yml` file. Remove any other `theme:` or `remote_theme:` entry.
8282

8383
You may also optionally specify a branch, [tag](https://github.com/mmistakes/minimal-mistakes/tags), or commit to use by appending an @ and the Git ref (e.g., `mmistakes/minimal-mistakes@4.9.0` or `mmistakes/minimal-mistakes@bbf3cbc5fd64a3e1885f3f99eb90ba92af84063d`). This is useful when rolling back to older versions of the theme. If you don't specify a Git ref, the latest on `master` will be used.
8484

‎docs/_docs/04-upgrading.md

+5-10
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,16 @@
22
title: "Upgrading"
33
permalink: /docs/upgrading/
44
excerpt: "Instructions and suggestions for upgrading the theme."
5-
last_modified_at: 2021-06-23T08:15:34-04:00
5+
last_modified_at: 2024-04-23T00:43:19+08:00
66
toc: true
77
---
88

99
If you're using the [Ruby Gem]({{ "/docs/quick-start-guide/#gem-based-method" | relative_url }}) or [remote theme]({{ "/docs/quick-start-guide/#remote-theme-method" | relative_url }}) versions of Minimal Mistakes, upgrading is fairly painless.
1010

1111
To check which version you are currently using, view the source of your built site and you should see something similar to:
1212

13-
```
14-
<!--
15-
Minimal Mistakes Jekyll Theme 4.24.0 by Michael Rose
16-
Copyright 2013-2020 Michael Rose - mademistakes.com | @mmistakes
17-
Free for personal and commercial use under the MIT license
18-
https://github.com/mmistakes/minimal-mistakes/blob/master/LICENSE
19-
-->
13+
```text
14+
{% include "copyright.html" %}
2015
```
2116

2217
At the top of every `.html` file, `/assets/css/main.css`, and `/assets/js/main.min.js`.
@@ -28,14 +23,14 @@ Simply run `bundle update` if you're using Bundler (have a `Gemfile`) or `gem up
2823
When using Bundler you can downgrade or lock the theme to a specific release ([tag](https://github.com/mmistakes/minimal-mistakes/tags)), branch, or commit. Instead of `gem "minimal-mistakes-jekyll"` you'd add the following to your `Gemfile`:
2924

3025
```ruby
31-
gem "minimal-mistakes-jekyll", :git => "https://github.com/mmistakes/minimal-mistakes.git", :tag => "4.24.0"
26+
gem "minimal-mistakes-jekyll", :git => "https://github.com/mmistakes/minimal-mistakes.git", :tag => "{{ site.theme_version }}"
3227
```
3328

3429
For more information on [installing gems from git repositories](http://bundler.io/v1.16/guides/git.html) consult Bundler's documentation.
3530

3631
## Remote theme
3732

38-
When setting `remote_theme: "mmistakes/minimal-mistakes@4.24.0"` in your `_config.yml` you may also optionally specify a branch, [tag](https://github.com/mmistakes/minimal-mistakes/tags), or commit to use by appending an @ and the Git ref.
33+
When setting `remote_theme: "mmistakes/minimal-mistakes@{{ site.theme_version }}"` in your `_config.yml` you may also optionally specify a branch, [tag](https://github.com/mmistakes/minimal-mistakes/tags), or commit to use by appending an @ and the Git ref.
3934

4035
For example you can roll back to release 4.8.1 with `mmistakes/minimal-mistakes@4.8.1` or a specific commit with `mmistakes/minimal-mistakes@bbf3cbc5fd64a3e1885f3f99eb90ba92af84063d`). For a complete list of theme versions consult the [releases page](https://github.com/mmistakes/minimal-mistakes/releases).
4136

‎docs/_layouts/default.html

+1-6
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,7 @@
22
---
33

44
<!doctype html>
5-
<!--
6-
Minimal Mistakes Jekyll Theme 4.24.0 by Michael Rose
7-
Copyright 2013-2020 Michael Rose - mademistakes.com | @mmistakes
8-
Free for personal and commercial use under the MIT license
9-
https://github.com/mmistakes/minimal-mistakes/blob/master/LICENSE
10-
-->
5+
{% include "copyright.html" %}
116
<html lang="{{ site.locale | slice: 0,2 | default: "en" }}" class="no-js">
127
<head>
138
{% include head.html %}

‎minimal-mistakes-jekyll.gemspec

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1-
# coding: utf-8
1+
require "json"
2+
3+
package_json = JSON.parse(File.read("package.json"))
24

35
Gem::Specification.new do |spec|
46
spec.name = "minimal-mistakes-jekyll"
5-
spec.version = "4.24.0"
6-
spec.authors = ["Michael Rose"]
7+
spec.version = package_json["version"]
8+
spec.authors = ["Michael Rose", "iBug"]
79

810
spec.summary = %q{A flexible two-column Jekyll theme.}
911
spec.homepage = "https://github.com/mmistakes/minimal-mistakes"

‎package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"description": "Minimal Mistakes 2 column Jekyll theme.",
66
"repository": {
77
"type": "git",
8-
"url": "git://github.com/mmistakes/minimal-mistakes.git"
8+
"url": "https://github.com/mmistakes/minimal-mistakes.git"
99
},
1010
"keywords": [
1111
"jekyll",

0 commit comments

Comments
 (0)
Please sign in to comment.