diff --git a/.github/config.yml b/.github/config.yml index dd20aa8e735..cb65f56f35e 100644 --- a/.github/config.yml +++ b/.github/config.yml @@ -14,7 +14,7 @@ requestInfoLabelToAdd: more-information-needed # Welcome! # Configuration for new-pr-welcome - https://github.com/behaviorbot/new-pr-welcome -newPRWelcomeComment: Welcome! Congrats on your first pull request to The Hacker Theme. If you haven't already, please be sure to check out [the contributing guidelines](https://github.com/pages-themes/hacker/blob/master/docs/CONTRIBUTING.md). +newPRWelcomeComment: Welcome! Congrats on your first pull request to the Hacker theme. If you haven't already, please be sure to check out [the contributing guidelines](https://github.com/pages-themes/hacker/blob/master/docs/CONTRIBUTING.md). # Configuration for first-pr-merge - https://github.com/behaviorbot/first-pr-merge -firstPRMergeComment: "Congrats on getting your first pull request to The Hacker Theme merged! Without amazing humans like you submitting pull requests, we couldn’t run this project. You rock! :tada:

If you're interested in tackling another bug or feature, take a look at [the open issues](https://github.com/pages-themes/hacker/issues), especially those [labeled `help wanted`](https://github.com/pages-themes/hacker/issues?q=is%3Aopen+is%3Aissue+label%3A%22help+wanted%22)." +firstPRMergeComment: "Congrats on getting your first pull request to the Hacker theme merged! Without amazing humans like you submitting pull requests, we couldn’t run this project. You rock! :tada:

If you're interested in tackling another bug or feature, take a look at [the open issues](https://github.com/pages-themes/hacker/issues), especially those [labeled `help wanted`](https://github.com/pages-themes/hacker/issues?q=is%3Aopen+is%3Aissue+label%3A%22help+wanted%22)." diff --git a/.github/settings.yml b/.github/settings.yml index 420815923f6..7c1b11592e1 100644 --- a/.github/settings.yml +++ b/.github/settings.yml @@ -26,6 +26,6 @@ branch_protection: required_status_checks: strict: true contexts: - - "continuous-integration/travis-ci" + - "script/cibuild" # GitHub Actions CI workflow required_pull_request_reviews: require_code_owner_reviews: true diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml new file mode 100644 index 00000000000..0323d522ef3 --- /dev/null +++ b/.github/workflows/ci.yaml @@ -0,0 +1,18 @@ +on: + push: + pull_request: + types: [opened, synchronize] +jobs: + build: + runs-on: ubuntu-latest + name: script/cibuild + steps: + - uses: actions/checkout@v2 + - uses: ruby/setup-ruby@v1 + with: + ruby-version: 3.2 + bundler-cache: true + - name: build + run: script/bootstrap + - name: test + run: script/cibuild diff --git a/.github/workflows/publish-gem.yml b/.github/workflows/publish-gem.yml new file mode 100644 index 00000000000..2e939a01811 --- /dev/null +++ b/.github/workflows/publish-gem.yml @@ -0,0 +1,22 @@ +name: Publish Gem + +on: + release: + types: [released] + +jobs: + release: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + - name: Setup Ruby + uses: ruby/setup-ruby@v1 + with: + ruby-version: '3.2' + - name: Build gem + run: | + gem build github-pages.gemspec + - name: Publish + run: | + gem push github-pages.gem --key ${{ secrets.PAGES_GEM_PUBLISH }} diff --git a/.gitignore b/.gitignore index 4c972ab54b0..822d5aaf017 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ _site .sass-cache Gemfile.lock *.gem +.jekyll-cache diff --git a/.rubocop.yml b/.rubocop.yml new file mode 100644 index 00000000000..15c823df623 --- /dev/null +++ b/.rubocop.yml @@ -0,0 +1,11 @@ +inherit_gem: + rubocop-github: + - config/default.yml + +AllCops: + Exclude: + - _site/**/* + - vendor/**/* + +Layout/LineLength: + Enabled: false diff --git a/.travis.yml b/.travis.yml index c2fa3f9c0ea..a871f2a9172 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,6 @@ language: ruby cache: bundler -sudo: false -rvm: 2.2 +rvm: 2.6 install: script/bootstrap script: script/cibuild diff --git a/Gemfile b/Gemfile index fa75df15632..be173b205f7 100644 --- a/Gemfile +++ b/Gemfile @@ -1,3 +1,5 @@ -source 'https://rubygems.org/' +# frozen_string_literal: true + +source "https://rubygems.org/" gemspec diff --git a/README.md b/README.md index 801d7a96ecd..4c2fac074ba 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,10 @@ # The Hacker theme -[![Build Status](https://travis-ci.org/pages-themes/hacker.svg?branch=master)](https://travis-ci.org/pages-themes/hacker) [![Gem Version](https://badge.fury.io/rb/jekyll-theme-hacker.svg)](https://badge.fury.io/rb/jekyll-theme-hacker) +[![.github/workflows/ci.yaml](https://github.com/pages-themes/hacker/actions/workflows/ci.yaml/badge.svg)](https://github.com/pages-themes/hacker/actions/workflows/ci.yaml) [![Gem Version](https://badge.fury.io/rb/jekyll-theme-hacker.svg)](https://badge.fury.io/rb/jekyll-theme-hacker) *Hacker is a Jekyll theme for GitHub Pages. You can [preview the theme to see what it looks like](http://pages-themes.github.io/hacker), or even [use it today](#usage).* -![Thumbnail of hacker](thumbnail.png) +![Thumbnail of Hacker](thumbnail.png) ## Usage @@ -13,7 +13,9 @@ To use the Hacker theme: 1. Add the following to your site's `_config.yml`: ```yml - theme: jekyll-theme-hacker + remote_theme: pages-themes/hacker@v0.2.0 + plugins: + - jekyll-remote-theme # add this line to the plugins list if you already have one ``` 2. Optionally, if you'd like to preview your site on your computer, add the following to your site's `Gemfile`: @@ -22,8 +24,6 @@ To use the Hacker theme: gem "github-pages", group: :jekyll_plugins ``` - - ## Customizing ### Configuration variables @@ -38,7 +38,7 @@ description: [A short description of your site's purpose] Additionally, you may choose to set the following optional variables: ```yml -show_downloads: ["true" or "false" to indicate whether to provide a download URL] +show_downloads: ["true" or "false" (unquoted) to indicate whether to provide a download URL] google_analytics: [Your Google Analytics tracking ID] ``` @@ -56,14 +56,38 @@ If you'd like to add your own custom styles: ``` 3. Add any custom CSS (or Sass, including imports) you'd like immediately after the `@import` line +*Note: If you'd like to change the theme's Sass variables, you must set new values before the `@import` line in your stylesheet.* + ### Layouts If you'd like to change the theme's HTML layout: -1. [Copy the original template](https://github.com/pages-themes/hacker/blob/master/_layouts/default.html) from the theme's repository
(*Pro-tip: click "raw" to make copying easier*) -2. Create a file called `/_layouts/default.html` in your site -3. Paste the default layout content copied in the first step -4. Customize the layout as you'd like +1. For some changes such as a custom `favicon`, you can add custom files in your local `_includes` folder. The files [provided with the theme](https://github.com/pages-themes/hacker/tree/master/_includes) provide a starting point and are included by the [original layout template](https://github.com/pages-themes/hacker/blob/master/_layouts/default.html). +2. For more extensive changes, [copy the original template](https://github.com/pages-themes/hacker/blob/master/_layouts/default.html) from the theme's repository
(*Pro-tip: click "raw" to make copying easier*) +3. Create a file called `/_layouts/default.html` in your site +4. Paste the default layout content copied in the first step +5. Customize the layout as you'd like + +### Customizing Google Analytics code + +Google has released several iterations to their Google Analytics code over the years since this theme was first created. If you would like to take advantage of the latest code, paste it into `_includes/head-custom-google-analytics.html` in your Jekyll site. + +### Overriding GitHub-generated URLs + +Templates often rely on URLs supplied by GitHub such as links to your repository or links to download your project. If you'd like to override one or more default URLs: + +1. Look at [the template source](https://github.com/pages-themes/hacker/blob/master/_layouts/default.html) to determine the name of the variable. It will be in the form of `{{ site.github.zip_url }}`. +2. Specify the URL that you'd like the template to use in your site's `_config.yml`. For example, if the variable was `site.github.url`, you'd add the following: + ```yml + github: + zip_url: http://example.com/download.zip + another_url: another value + ``` +3. When your site is built, Jekyll will use the URL you specified, rather than the default one provided by GitHub. + +*Note: You must remove the `site.` prefix, and each variable name (after the `github.`) should be indent with two space below `github:`.* + +For more information, see [the Jekyll variables documentation](https://jekyllrb.com/docs/variables/). ## Roadmap @@ -75,7 +99,7 @@ The Hacker theme is intended to make it quick and easy for GitHub Pages users to ## Contributing -Interested in contributing to Hacker? We'd love your help. Hacker is an open source project, built one contribution at a time by users like you. See [the CONTRIBUTING file](CONTRIBUTING.md) for instructions on how to contribute. +Interested in contributing to Hacker? We'd love your help. Hacker is an open source project, built one contribution at a time by users like you. See [the CONTRIBUTING file](docs/CONTRIBUTING.md) for instructions on how to contribute. ### Previewing the theme locally @@ -89,4 +113,4 @@ If you'd like to preview the theme locally (for example, in the process of propo ### Running tests -The theme contains a minimal test suite, to ensure a site with the theme would build successfully. To run the tests, simply run `script/cibuild`. You'll need to run `script/bootstrap` one before the test script will work. +The theme contains a minimal test suite, to ensure a site with the theme would build successfully. To run the tests, simply run `script/cibuild`. You'll need to run `script/bootstrap` once before the test script will work. diff --git a/_includes/head-custom-google-analytics.html b/_includes/head-custom-google-analytics.html new file mode 100644 index 00000000000..8a3ae5c9ca1 --- /dev/null +++ b/_includes/head-custom-google-analytics.html @@ -0,0 +1,10 @@ +{% if site.google_analytics %} + +{% endif %} diff --git a/_includes/head-custom-theme-colors.html b/_includes/head-custom-theme-colors.html new file mode 100644 index 00000000000..a30e7084adf --- /dev/null +++ b/_includes/head-custom-theme-colors.html @@ -0,0 +1,5 @@ + + + + + diff --git a/_includes/head-custom.html b/_includes/head-custom.html new file mode 100644 index 00000000000..44cdb83f523 --- /dev/null +++ b/_includes/head-custom.html @@ -0,0 +1,12 @@ + + + +{% include head-custom-theme-colors.html %} + + +{% include head-custom-google-analytics.html %} + + + + + diff --git a/_layouts/default.html b/_layouts/default.html index f8ccdd2f72f..1c8c883a480 100644 --- a/_layouts/default.html +++ b/_layouts/default.html @@ -2,9 +2,10 @@ - + + {% include head-custom.html %} {% seo %} @@ -13,7 +14,9 @@
-

{{ site.title | default: site.github.repository_name }}

+ +

{{ site.title | default: site.github.repository_name }}

+

{{ site.description | default: site.github.project_tagline }}

@@ -31,16 +34,5 @@

{{ site.description | default: site.github.project_tagline }}

{{ content }}
- - {% if site.google_analytics %} - - {% endif %} diff --git a/_layouts/post.html b/_layouts/post.html new file mode 100644 index 00000000000..0676aff31c4 --- /dev/null +++ b/_layouts/post.html @@ -0,0 +1,14 @@ +--- +layout: default +--- + +{{ page.date | date: "%-d %B %Y" }} +

{{ page.title }}

+ +

by {{ page.author | default: site.author }}

+ +{{content}} + +{% if page.tags %} + tags: {{ page.tags | join: " - " }} +{% endif %} diff --git a/_sass/hacker.scss b/_sass/hacker.scss new file mode 100644 index 00000000000..b535d24dfbb --- /dev/null +++ b/_sass/hacker.scss @@ -0,0 +1,4 @@ +// Placeholder file. If your site uses +// @import "https://github.com/%7B%7B%20site.theme%20%7D%7D"; +// Then using this theme with jekyll-remote-theme will work fine. +@import "https://github.com/jekyll-theme-hacker"; diff --git a/_sass/jekyll-theme-hacker.scss b/_sass/jekyll-theme-hacker.scss index bca8aa1448e..b3123a11ce3 100644 --- a/_sass/jekyll-theme-hacker.scss +++ b/_sass/jekyll-theme-hacker.scss @@ -6,6 +6,13 @@ $body-foreground: $gallery !default; $header: $conifer !default; $blockquote-color: $silver-chalice !default; $blockquote-border: $dove-grey !default; +$container-max-width: 1000px; + +@mixin media-max-width($max-width) { + @media (max-width: $max-width) { + @content; + } +} body { margin: 0; @@ -21,7 +28,7 @@ body { .container { width: 90%; - max-width: 600px; + max-width: $container-max-width; margin: 0 auto; } @@ -64,8 +71,12 @@ header h1 { 0 0 10px rgba(181, 232, 83, 0.1); letter-spacing: -1px; -webkit-font-smoothing: antialiased; + @include media-max-width($container-max-width) { + margin-left: 0; + } } + header h1:before { content: "./ "; font-size: 24px; @@ -155,7 +166,7 @@ pre { font-size: 16px; color: #b5e853; border-radius: 2px; - text-wrap: normal; + word-wrap: normal; overflow: auto; overflow-y: hidden; } @@ -251,3 +262,7 @@ a { .cf { zoom:1; } + +#a-title { + text-decoration: none; +} diff --git a/docs/CONTRIBUTING.md b/docs/CONTRIBUTING.md index 99259dc9725..f59423126a9 100644 --- a/docs/CONTRIBUTING.md +++ b/docs/CONTRIBUTING.md @@ -1,8 +1,8 @@ -# Contributing to The Hacker Theme +# Contributing to the Hacker theme -Hi there! We're thrilled that you'd like to contribute to The Hacker Theme. Your help is essential for keeping it great. +Hi there! We're thrilled that you'd like to contribute to the Hacker theme. Your help is essential for keeping it great. -The Hacker Theme is an open source project supported by the efforts of an entire community and built one contribution at a time by users like you. We'd love for you to get involved. Whatever your level of skill or however much time you can give, your contribution is greatly appreciated. There are many ways to contribute, from writing tutorials or blog posts, improving the documentation, submitting bug reports and feature requests, helping other users by commenting on issues, or writing code which can be incorporated into The Hacker Theme itself. +the Hacker theme is an open source project supported by the efforts of an entire community and built one contribution at a time by users like you. We'd love for you to get involved. Whatever your level of skill or however much time you can give, your contribution is greatly appreciated. There are many ways to contribute, from writing tutorials or blog posts, improving the documentation, submitting bug reports and feature requests, helping other users by commenting on issues, or writing code which can be incorporated into the Hacker theme itself. Following these guidelines helps to communicate that you respect the time of the developers managing and developing this open source project. In return, they should reciprocate that respect in addressing your issue, assessing changes, and helping you finalize your pull requests. @@ -28,7 +28,7 @@ Here are a few tips for writing *great* bug reports: ## How to suggest a feature or enhancement -If you find yourself wishing for a feature that doesn't exist in The Hacker Theme, you are probably not alone. There are bound to be others out there with similar needs. Many of the features that The Hacker Theme has today have been added because our users saw the need. +If you find yourself wishing for a feature that doesn't exist in the Hacker theme, you are probably not alone. There are bound to be others out there with similar needs. Many of the features that the Hacker theme has today have been added because our users saw the need. Feature requests are welcome. But take a moment to find out whether your idea fits with the scope and goals of the project. It's up to you to make a strong case to convince the project's developers of the merits of this feature. Please provide as much detail and context as possible, including describing the problem you're trying to solve. @@ -38,7 +38,7 @@ Feature requests are welcome. But take a moment to find out whether your idea fi ## Your first contribution -We'd love for you to contribute to the project. Unsure where to begin contributing to The Hacker Theme? You can start by looking through these "good first issue" and "help wanted" issues: +We'd love for you to contribute to the project. Unsure where to begin contributing to the Hacker theme? You can start by looking through these "good first issue" and "help wanted" issues: * [Good first issues](https://github.com/pages-themes/hacker/issues?q=is%3Aissue+is%3Aopen+label%3A%22good+first+issue%22) - issues which should only require a few lines of code and a test or two * [Help wanted issues](https://github.com/pages-themes/hacker/issues?q=is%3Aissue+is%3Aopen+label%3A%22help+wanted%22) - issues which may be a bit more involved, but are specifically seeking community contributions @@ -77,6 +77,9 @@ At a high level, [the process for proposing changes](https://guides.github.com/i `script/cibuild` +## Publishing Gem +In order to publish the Gem bump the version in *this file*, commit, create a tag with the new version number, and finally push the commit and tag to the repo. + ## Code of conduct This project is governed by [the Contributor Covenant Code of Conduct](CODE_OF_CONDUCT.md). By participating, you are expected to uphold this code. diff --git a/docs/SUPPORT.md b/docs/SUPPORT.md index 09915fe9577..db7a5321ab3 100644 --- a/docs/SUPPORT.md +++ b/docs/SUPPORT.md @@ -1,9 +1,9 @@ ## Where to get help -If you think you've found a bug in The Hacker Theme, please [check the existing issues](https://github.com/pages-themes/hacker/issues), and if no one has reported the problem, [open a new issue](https://github.com/pages-themes/hacker/issues/new). +If you think you've found a bug in the Hacker theme, please [check the existing issues](https://github.com/pages-themes/hacker/issues), and if no one has reported the problem, [open a new issue](https://github.com/pages-themes/hacker/issues/new). -If you have a general question about the theme, how to implement it, or how to customize it for your site you have two options: - -1. [Contact GitHub Support](https://github.com/contact?form%5Bsubject%5D=GitHub%20Pages%20theme%20pages-themes/hacker), or +If you have a general question about the theme, how to implement it, or how to customize it for your site you have two options: +1. Search for your query on [`support.github.com`](https://support.github.com/?q=pages+Hacker+theme), which will also look for similar topics on [`github.community`](https://github.community/search?q=pages+Hacker+theme) 2. Ask your question of the Jekyll community on [talk.jekyllrb.com](https://talk.jekyllrb.com/) +3. [Contact GitHub Support](https://github.com/contact?form%5Bsubject%5D=GitHub%20Pages%20theme%20pages-themes/hacker) diff --git a/index.md b/index.md index 8ee80b68030..e039c9ac641 100644 --- a/index.md +++ b/index.md @@ -4,23 +4,23 @@ layout: default Text can be **bold**, _italic_, ~~strikethrough~~ or `keyword`. -[Link to another page](another-page). +[Link to another page](./another-page.html). There should be whitespace between paragraphs. There should be whitespace between paragraphs. We recommend including a README, or a file with information about your project. -# [](#header-1)Header 1 +# Header 1 This is a normal paragraph following a header. GitHub is a code hosting platform for version control and collaboration. It lets you and others work together on projects from anywhere. -## [](#header-2)Header 2 +## Header 2 > This is a blockquote following a header. > > When something is important enough, you do it even if the odds are not in your favor. -### [](#header-3)Header 3 +### Header 3 ```js // Javascript code with syntax highlighting. @@ -37,19 +37,19 @@ GitHubPages::Dependencies.gems.each do |gem, version| end ``` -#### [](#header-4)Header 4 +#### Header 4 * This is an unordered list following a header. * This is an unordered list following a header. * This is an unordered list following a header. -##### [](#header-5)Header 5 +##### Header 5 1. This is an ordered list following a header. 2. This is an ordered list following a header. 3. This is an ordered list following a header. -###### [](#header-6)Header 6 +###### Header 6 | head1 | head two | three | |:-------------|:------------------|:------| @@ -94,11 +94,11 @@ end ### Small image -![](https://assets-cdn.github.com/images/icons/emoji/octocat.png) +![Octocat](https://github.githubassets.com/images/icons/emoji/octocat.png) ### Large image -![](https://guides.github.com/activities/hello-world/branching.png) +![Branching](https://guides.github.com/activities/hello-world/branching.png) ### Definition lists can be used with HTML syntax. diff --git a/jekyll-theme-hacker.gemspec b/jekyll-theme-hacker.gemspec index 5a9729b3867..893e841f9b8 100644 --- a/jekyll-theme-hacker.gemspec +++ b/jekyll-theme-hacker.gemspec @@ -1,8 +1,8 @@ -# encoding: utf-8 +# frozen_string_literal: true Gem::Specification.new do |s| s.name = "jekyll-theme-hacker" - s.version = "0.1.0" + s.version = "0.2.0" s.license = "CC0-1.0" s.authors = ["Jason Costello", "GitHub, Inc."] s.email = ["opensource+jekyll-theme-hacker@github.com"] @@ -13,7 +13,12 @@ Gem::Specification.new do |s| f.match(%r{^((_includes|_layouts|_sass|assets)/|(LICENSE|README)((\.(txt|md|markdown)|$)))}i) end - s.platform = Gem::Platform::RUBY - s.add_runtime_dependency "jekyll", "~> 3.5" + s.required_ruby_version = ">= 2.4.0" + + s.platform = Gem::Platform::RUBY + s.add_runtime_dependency "jekyll", "> 3.5", "< 5.0" s.add_runtime_dependency "jekyll-seo-tag", "~> 2.0" + s.add_development_dependency "html-proofer", "~> 3.0" + s.add_development_dependency "rubocop-github", "~> 0.16" + s.add_development_dependency "w3c_validators", "~> 1.3" end diff --git a/script/cibuild b/script/cibuild index 5a4da9a5846..308ad64a91b 100755 --- a/script/cibuild +++ b/script/cibuild @@ -3,4 +3,7 @@ set -e bundle exec jekyll build +bundle exec htmlproofer ./_site --check-html --check-sri +bundle exec rubocop -D --config .rubocop.yml +bundle exec script/validate-html gem build jekyll-theme-hacker.gemspec diff --git a/script/validate-html b/script/validate-html new file mode 100755 index 00000000000..8f51642ea54 --- /dev/null +++ b/script/validate-html @@ -0,0 +1,28 @@ +#!/usr/bin/env ruby +# frozen_string_literal: true + +require "w3c_validators" + +def validator(file) + extension = File.extname(file) + if extension == ".html" + W3CValidators::NuValidator.new + elsif extension == ".css" + W3CValidators::CSSValidator.new + end +end + +def validate(file) + puts "Checking #{file}..." + + path = File.expand_path "../_site/#{file}", __dir__ + results = validator(file).validate_file(path) + + return puts "Valid!" if results.errors.empty? + + results.errors.each { |err| puts err } + exit 1 +end + +validate "index.html" +validate File.join "assets", "css", "style.css"