Skip to content

Commit

Permalink
Consolidate hard-coded version numbers where possible
Browse files Browse the repository at this point in the history
Now only 4 files left untouchable.
Search README.md for "Dev note" for details.
  • Loading branch information
iBug committed Apr 22, 2024
1 parent aae8dac commit 8d3592f
Show file tree
Hide file tree
Showing 14 changed files with 106 additions and 56 deletions.
32 changes: 24 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,22 +115,42 @@ To install:

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

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

```bash
bundle
```

4. Add `remote_theme: "mmistakes/[email protected]"` to your `_config.yml` file. Remove any other `theme:` or `remote_theme:` entry.

<!--
Dev note: The version number is currently hard-coded in these files:

- README.md (this file)
- package.json
- docs/_config.yml (as theme_version)
- docs/_pages/home.md (in Front Matter "excerpt")

For every release, files listed above should be manually updated with the new version number.

Additionally, the license year is hard-coded in these files:

- README.md (this file, near the end)
- LICENSE

The following files should also be regenerated:

- _includes/copyright.html, _includes/copyright.js, _sass/minimal-mistakes/_copyright.scss
(Run `bundle exec rake clean` then `bundle exec rake copyright` - all three references `package.json`)
- assets/js/main.min.js (Run `npm run build:js`, references `_includes/copyright.js`)
-->

**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.

## Usage

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/).

---

## Contributing

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.
Expand All @@ -153,8 +173,6 @@ To set up your environment to develop this theme, run `bundle install`.

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.

---

## Credits

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

### Icons + Demo Images:

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

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

---

## License

The MIT License (MIT)
Expand Down
43 changes: 43 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
require "bundler/gem_tasks"
require "jekyll"
require "json"
require "listen"
require "rake/clean"
require "time"
require "yaml"

package_json = JSON.parse(File.read("package.json"))

def listen_ignore_paths(base, options)
[
/_config\.ya?ml/,
Expand Down Expand Up @@ -101,3 +105,42 @@ file "docs/_docs/18-history.md" => "CHANGELOG.md" do |t|
f.puts "{% endraw %}"
end
end

COPYRIGHT_LINES = [
"Minimal Mistakes Jekyll Theme #{package_json["version"]} by Michael Rose",
"Copyright 2013-2020 Michael Rose - mademistakes.com | @mmistakes",
"Free for personal and commercial use under the MIT license",
"https://github.com/mmistakes/minimal-mistakes/blob/master/LICENSE",
]

COPYRIGHT_FILES = [
"_includes/copyright.html",
"_includes/copyright.js",
"_sass/minimal-mistakes/_copyright.scss",
]

def genenerate_copyright_file(filename, header, prefix, footer)
File.open(filename, "w") do |f|
f.puts header
COPYRIGHT_LINES.each do |line|
f.puts "#{prefix}#{line}"
end
f.puts footer
end
end

file "_includes/copyright.html" do |t|
genenerate_copyright_file(t.name, "<!--", " ", "-->")
end

file "_includes/copyright.js" do |t|
genenerate_copyright_file(t.name, "/*!", " * ", " */")
end

file "_sass/minimal-mistakes/_copyright.scss" do |t|
genenerate_copyright_file(t.name, "/*!", " * ", " */")
end

task :copyright => COPYRIGHT_FILES

CLEAN.include(*COPYRIGHT_FILES)
6 changes: 6 additions & 0 deletions _includes/copyright.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<!--
Minimal Mistakes Jekyll Theme 4.24.0 by Michael Rose
Copyright 2013-2020 Michael Rose - mademistakes.com | @mmistakes
Free for personal and commercial use under the MIT license
https://github.com/mmistakes/minimal-mistakes/blob/master/LICENSE
-->
6 changes: 6 additions & 0 deletions _includes/copyright.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/*!
* Minimal Mistakes Jekyll Theme 4.24.0 by Michael Rose
* Copyright 2013-2020 Michael Rose - mademistakes.com | @mmistakes
* Free for personal and commercial use under the MIT license
* https://github.com/mmistakes/minimal-mistakes/blob/master/LICENSE
*/
7 changes: 1 addition & 6 deletions _layouts/default.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,7 @@
---

<!doctype html>
<!--
Minimal Mistakes Jekyll Theme 4.24.0 by Michael Rose
Copyright 2013-2020 Michael Rose - mademistakes.com | @mmistakes
Free for personal and commercial use under the MIT license
https://github.com/mmistakes/minimal-mistakes/blob/master/LICENSE
-->
{% include "copyright.html" %}
<html lang="{{ site.locale | slice: 0,2 | default: "en" }}" class="no-js">
<head>
{% include head.html %}
Expand Down
7 changes: 2 additions & 5 deletions _sass/minimal-mistakes.scss
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
/*!
* Minimal Mistakes Jekyll Theme 4.24.0 by Michael Rose
* Copyright 2013-2020 Michael Rose - mademistakes.com | @mmistakes
* Licensed under MIT (https://github.com/mmistakes/minimal-mistakes/blob/master/LICENSE)
*/
/* Copyright comment */
@import "minimal-mistakes/copyright";

/* Variables */
@import "minimal-mistakes/variables";
Expand Down
6 changes: 6 additions & 0 deletions _sass/minimal-mistakes/_copyright.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/*!
* Minimal Mistakes Jekyll Theme 4.24.0 by Michael Rose
* Copyright 2013-2020 Michael Rose - mademistakes.com | @mmistakes
* Free for personal and commercial use under the MIT license
* https://github.com/mmistakes/minimal-mistakes/blob/master/LICENSE
*/
18 changes: 3 additions & 15 deletions banner.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,7 @@
const fs = require("fs");
const pkg = require("./package.json");
const filename = "assets/js/main.min.js";
const script = fs.readFileSync(filename);
const padStart = str => ("0" + str).slice(-2);
const dateObj = new Date();
const date = `${dateObj.getFullYear()}-${padStart(
dateObj.getMonth() + 1
)}-${padStart(dateObj.getDate())}`;
const banner = `/*!
* Minimal Mistakes Jekyll Theme ${pkg.version} by ${pkg.author}
* Copyright 2013-${dateObj.getFullYear()} Michael Rose - mademistakes.com | @mmistakes
* Licensed under ${pkg.license}
*/
`;
const script = fs.readFileSync("assets/js/main.min.js");
const banner = fs.readFileSync("_includes/copyright.js");

if (script.slice(0, 3) != "/**") {
if (script.slice(0, 3) != "/*!") {
fs.writeFileSync(filename, banner + script);
}
3 changes: 2 additions & 1 deletion docs/_config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
# For technical reasons, this file is *NOT* reloaded automatically when you use
# `jekyll serve`. If you change this file, please restart the server process.

remote_theme : "mmistakes/[email protected]"
remote_theme : "mmistakes/minimal-mistakes@master"
theme_version : "4.24.0"

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

Expand Down
2 changes: 1 addition & 1 deletion docs/_docs/01-quick-start-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ To install as a remote theme:
bundle
```

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

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/[email protected]` 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.

Expand Down
15 changes: 5 additions & 10 deletions docs/_docs/04-upgrading.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,16 @@
title: "Upgrading"
permalink: /docs/upgrading/
excerpt: "Instructions and suggestions for upgrading the theme."
last_modified_at: 2021-06-23T08:15:34-04:00
last_modified_at: 2024-04-23T00:43:19+08:00
toc: true
---

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.

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

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

At the top of every `.html` file, `/assets/css/main.css`, and `/assets/js/main.min.js`.
Expand All @@ -28,14 +23,14 @@ Simply run `bundle update` if you're using Bundler (have a `Gemfile`) or `gem up
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`:

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

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

## Remote theme

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.
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.

For example you can roll back to release 4.8.1 with `mmistakes/[email protected]` 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).

Expand Down
7 changes: 1 addition & 6 deletions docs/_layouts/default.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,7 @@
---

<!doctype html>
<!--
Minimal Mistakes Jekyll Theme 4.24.0 by Michael Rose
Copyright 2013-2020 Michael Rose - mademistakes.com | @mmistakes
Free for personal and commercial use under the MIT license
https://github.com/mmistakes/minimal-mistakes/blob/master/LICENSE
-->
{% include "copyright.html" %}
<html lang="{{ site.locale | slice: 0,2 | default: "en" }}" class="no-js">
<head>
{% include head.html %}
Expand Down
8 changes: 5 additions & 3 deletions minimal-mistakes-jekyll.gemspec
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
# coding: utf-8
require "json"

package_json = JSON.parse(File.read("package.json"))

Gem::Specification.new do |spec|
spec.name = "minimal-mistakes-jekyll"
spec.version = "4.24.0"
spec.authors = ["Michael Rose"]
spec.version = package_json["version"]
spec.authors = ["Michael Rose", "iBug"]

spec.summary = %q{A flexible two-column Jekyll theme.}
spec.homepage = "https://github.com/mmistakes/minimal-mistakes"
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"description": "Minimal Mistakes 2 column Jekyll theme.",
"repository": {
"type": "git",
"url": "git://github.com/mmistakes/minimal-mistakes.git"
"url": "https://github.com/mmistakes/minimal-mistakes.git"
},
"keywords": [
"jekyll",
Expand Down

0 comments on commit 8d3592f

Please sign in to comment.