Skip to content

Commit

Permalink
x
Browse files Browse the repository at this point in the history
encse committed Nov 17, 2024
1 parent 55f3f0a commit e1040c0
Showing 3 changed files with 20 additions and 43 deletions.
25 changes: 0 additions & 25 deletions Lib/Generator/ReadmeGenerator.cs
Original file line number Diff line number Diff line change
@@ -2,31 +2,6 @@

namespace AdventOfCode.Generator;

class ProjectReadmeGenerator {
public string Generate(int firstYear, int lastYear) {

return $"""
# Advent of Code ({firstYear}-{lastYear})
C# solutions to the [Advent of Code](https://adventofcode.com) problems.
<a href="https://adventofcode.com"><img src="{lastYear}/calendar.svg" width="80%" /></a>
If you want to use my framework, it's probably easiest to start out from the
https://github.com/encse/adventofcode-template repository.
I put a lot of effort into my solutions. I aim for clarity, which means that
they are not super effective or super short, but hopefully more readable.
If you find project useful, please [support](https://github.com/sponsors/encse) me.
## Dependencies
- Based on `.NET 8` and `C# 12`.
- `AngleSharp` is used for problem download.
- git-crypt to store the input files in an encrypted form
""";
}
}

class ReadmeGeneratorForYear {
public string Generate(Calendar calendar) {
return $"""
6 changes: 0 additions & 6 deletions Lib/Updater.cs
Original file line number Diff line number Diff line change
@@ -49,7 +49,6 @@ public async Task Update(int year, int day) {
years = new int[] { year };
}

UpdateProjectReadme(years.Min(), years.Max());
UpdateReadmeForYear(calendar);
UpdateSplashScreen(calendar);
UpdateReadmeForDay(problem);
@@ -205,11 +204,6 @@ void UpdateSolutionTemplate(Problem problem) {
}
}

void UpdateProjectReadme(int firstYear, int lastYear) {
var file = Path.Combine("README.md");
WriteFile(file, new ProjectReadmeGenerator().Generate(firstYear, lastYear));
}

void UpdateReadmeForYear(Calendar calendar) {
var file = Path.Combine(SolverExtensions.WorkingDir(calendar.Year), "README.md");
WriteFile(file, new ReadmeGeneratorForYear().Generate(calendar));
32 changes: 20 additions & 12 deletions docs/index.html
Original file line number Diff line number Diff line change
@@ -111,15 +111,14 @@
padding: 1em;
}

#top-nav select {
#year-picker select {
border: none;
background: inherit;
color: inherit;
font-size: inherit;
color: inherit;
-webkit-appearance: none;
-moz-appearance: none;
appearance: none;
background: none;
}

#top-nav a,
@@ -142,16 +141,19 @@

#top-nav {
display: flex;
flex-wrap: wrap;
justify-content: center;
}

#top-nav select {
margin-left: 1em;
margin-right: 1em;
}

#top-nav a {
#day-picker {
display: flex;
flex-wrap: wrap;
}

#day-picker a {
margin: 1em;
}

@@ -205,7 +207,10 @@
</head>

<body lang="en-US">
<div id="top-nav"></div>
<div id="top-nav">
<div id="year-picker"></div>
<div id="day-picker"></div>
</div>
<div class="main">
<div class="header-container">
<div class="header-image">
@@ -324,8 +329,9 @@ <h2 id="problem-name"></h2>
}
});

let topNav = document.getElementById('top-nav');
if (topNav) {
let yearPickerDiv = document.getElementById('year-picker');
let dayPickerDiv = document.getElementById('day-picker');
if (yearPickerDiv) {
const yearPicker = document.createElement('select')
for (let y = 2015; y <= lastUnlockedYear; y++) {
let q = y;
@@ -336,12 +342,14 @@ <h2 id="problem-name"></h2>
option.onselect = () => alert(q);
yearPicker.appendChild(option)
}
topNav.appendChild(yearPicker);
yearPickerDiv.appendChild(yearPicker);

yearPicker.addEventListener('change', function () {
window.location.search = this.value;
});

}

if (dayPickerDiv) {
for (i = 1; i <= lastUnlockedDay; i++) {
const span = document.createElement('span');
let link = document.createElement('a');
@@ -351,7 +359,7 @@ <h2 id="problem-name"></h2>
span.classList.add("current");
}
span.appendChild(link);
topNav.appendChild(span);
dayPickerDiv.appendChild(span);
}
}
</script>

0 comments on commit e1040c0

Please sign in to comment.