Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update master #31

Closed
wants to merge 9 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/deploy-gh-pages.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Deploy mdBook to GH Pages
on:
push:
branches:
- 'master'
- "master"

jobs:
deploy:
Expand All @@ -16,7 +16,7 @@ jobs:
- name: Setup mdBook
uses: peaceiris/[email protected]
with:
mdbook-version: 'latest'
mdbook-version: "latest"

- run: mdbook build

Expand Down
31 changes: 15 additions & 16 deletions .github/workflows/stale.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,28 +7,27 @@ name: Mark stale issues and pull requests

on:
schedule:
- cron: '0 7 * * *'
- cron: "0 7 * * *"

jobs:
stale:

runs-on: ubuntu-latest
permissions:
issues: write
pull-requests: write

steps:
- uses: actions/stale@v4
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
stale-issue-message: 'This issue is stale because it has been open 30 days with no activity. Remove stale label, comment or add the valid label or this will be closed in 5 days.'
stale-pr-message: 'This pull request is stale because it has been open 30 days with no activity. Remove stale label, comment or add the valid label or this will be closed in 5 days.'
stale-issue-label: 'stale'
stale-pr-label: 'stale'
close-issue-label: 'inactivity-closed'
close-pr-label: 'inactivity-closed'
labels-to-add-when-unstale: 'valid'
exempt-issue-labels: 'valid,good first issue'
exempt-pr-labels: 'valid,good first issue'
days-before-stale: 30
days-before-close: 5
- uses: actions/stale@v4
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
stale-issue-message: "This issue is stale because it has been open 30 days with no activity. Remove stale label, comment or add the valid label or this will be closed in 5 days."
stale-pr-message: "This pull request is stale because it has been open 30 days with no activity. Remove stale label, comment or add the valid label or this will be closed in 5 days."
stale-issue-label: "stale"
stale-pr-label: "stale"
close-issue-label: "inactivity-closed"
close-pr-label: "inactivity-closed"
labels-to-add-when-unstale: "valid"
exempt-issue-labels: "valid,good first issue"
exempt-pr-labels: "valid,good first issue"
days-before-stale: 30
days-before-close: 5
2 changes: 1 addition & 1 deletion .markdownlint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ MD007:
MD013:
line_length: 300
MD033:
allowed_elements: ["iframe", "sup"]
allowed_elements: ["iframe", "sup"]
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

Book teaching how to write modern and effective Java. It is maintained by the community, anyone can contribute.

Feel free to join our [discord server](https://discord.com/invite/XXFUXzK)
Feel free to join our [discord server](https://discord.gg/together-java-272761734820003841)
if you have any questions, or require assistance with the project. :relaxed:

## Getting started
Expand Down
21 changes: 11 additions & 10 deletions book.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,17 @@ multilingual = false
git-repository-url = "https://github.com/Together-Java/ModernJava"
edit-url-template = "https://github.com/Together-Java/ModernJava/edit/develop/{path}"
mathjax-support = true
additional-css = ["ferris.css"]
additional-js = ["ferris.js"]

[output.html.fold]
enable = true # whether or not to enable section folding
level = 0 # the depth to start folding
enable = true # whether or not to enable section folding
level = 0 # the depth to start folding

[preprocessor.features]
command = "python3 features.java"
# Not ready
toplevel_anonymous_class = false
# Not ready
simple_io = false
# Turn on when Java 21 released
java_21 = false
[output.html.playground]
editable = true

[output.html.code.hidelines]
java = "~"
[output.html.code.hidelines]
java = "~"
55 changes: 0 additions & 55 deletions features.java

This file was deleted.

45 changes: 45 additions & 0 deletions ferris.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
body.light .does_not_compile,
body.light .panics,
body.light .not_desired_behavior,
body.rust .does_not_compile,
body.rust .panics,
body.rust .not_desired_behavior {
background: #fff1f1;
}

body.coal .does_not_compile,
body.coal .panics,
body.coal .not_desired_behavior,
body.navy .does_not_compile,
body.navy .panics,
body.navy .not_desired_behavior,
body.ayu .does_not_compile,
body.ayu .panics,
body.ayu .not_desired_behavior {
background: #501f21;
}

.ferris-container {
position: absolute;
z-index: 99;
right: 5px;
top: 30px;
}

.ferris {
vertical-align: top;
margin-left: 0.2em;
height: auto;
}

.ferris-large {
width: 4.5em;
}

.ferris-small {
width: 2.3em;
}

.ferris-explain {
width: 100px;
}
65 changes: 65 additions & 0 deletions ferris.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
var ferrisTypes = [
{
attr: 'does_not_compile',
title: 'This code does not compile!'
},
{
attr: 'panics',
title: 'This code will crash!'
},
{
attr: 'not_desired_behavior',
title: 'This code does not produce the desired behavior.'
}
]

document.addEventListener('DOMContentLoaded', () => {
for (var ferrisType of ferrisTypes) {
attachFerrises(ferrisType)
}
})

function attachFerrises(type) {
var elements = document.getElementsByClassName(type.attr)

for (var codeBlock of elements) {
var lines = codeBlock.innerText.replace(/\n$/, '').split(/\n/).length
var size = 'large'
if (lines < 5) {
size = 'small'
}

var container = prepareFerrisContainer(codeBlock, size == 'small')
container.appendChild(createFerris(type, size))
}
}

function prepareFerrisContainer(element, useButtons) {
var foundButtons = element.parentElement.querySelector('.buttons')
if (useButtons && foundButtons) {
return foundButtons
}

var div = document.createElement('div')
div.classList.add('ferris-container')

element.parentElement.insertBefore(div, element)

return div
}

function createFerris(type, size) {
var a = document.createElement('a')
// a.setAttribute('href', 'ch00-00-introduction.html#ferris')
a.setAttribute('target', '_blank')

var img = document.createElement('img')
img.setAttribute('src', '../img/' + type.attr + '.svg')
img.setAttribute('title', type.title)
img.classList.add('ferris')
img.classList.add('ferris-' + size)

a.appendChild(img)

return a
}
Loading
Loading