Skip to content

Commit 8a14168

Browse files
committed
Removed "overthinked" features
re #9
1 parent ab3bc70 commit 8a14168

File tree

4 files changed

+48
-59
lines changed

4 files changed

+48
-59
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Kotlog CLI dev
22

3-
__output/
3+
__output/*
44

55
#
66
# Build artifacts

__output/index.html

Lines changed: 22 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -3,33 +3,16 @@
33

44
<head>
55
<meta charset="utf-8">
6-
<title>Tobias Scholze | The Stuttering Nerd</title>
76
<meta name="description" content="">
87
<meta name="viewport" content="width=device-width, initial-scale=1">
98

10-
<link rel="icon" href="/favicon.ico" sizes="any">
11-
<link rel="icon" href="/icon.svg" type="image/svg+xml">
12-
13-
<link rel="stylesheet" href="style.css">
14-
15-
<style>
16-
header,
17-
footer {
18-
font-size: 0.75rem;
19-
font-style: italic;
20-
text-align: center;
21-
}
9+
<title>Tobias Scholze | The Stuttering Nerd</title>
2210

23-
footer {
24-
padding-top: 32px;
25-
}
11+
<link rel="icon" href="favicon.ico" sizes="any">
12+
<link rel="icon" href="icon.svg" type="image/svg+xml">
13+
<link rel="apple-touch-icon" sizes="180x180" href="apple-touch-icon.png">
2614

27-
img {
28-
display:block;
29-
margin-left:auto;
30-
margin-right:auto;
31-
}
32-
</style>
15+
<link rel="stylesheet" href="style.css">
3316
</head>
3417

3518
<header>
@@ -38,19 +21,22 @@
3821
</header>
3922

4023
<content>
41-
<h1>Tobias Scholze | The Stuttering Nerd</h1>
24+
<h1>Blog</h1>
4225
<div class="snippet">
4326
<a href="2022-09-16-hi-i-m-kotlog-.html">Hi, I'm Kotlog!</a>
44-
</div>~<div class="snippet">
45-
<a href="2021-01-23-raspberry-pi-hi-du-pico.html">Hi du Raspberry Pi!</a>
27+
</div>
28+
29+
<h3>Archive (from the far away past)</h3>
30+
<div class="snippet">
31+
<a href="2021-01-23-raspberry-pi-hi-du-pico.html">Hi du Raspberry Pi Pico!</a>
4632
</div>~<div class="snippet">
4733
<a href="2021-01-16-persoenliches-meine-github-top-5-projekte-video.html">Meine GitHub TOP 5 Projekte (Video)</a>
4834
</div>~<div class="snippet">
4935
<a href="2020-11-21-oh-hai-apple-mac-mini-m1.html">Oh, hai Apple Mac mini M1</a>
5036
</div>~<div class="snippet">
5137
<a href="2020-09-12-persoenliches-mein-youtube-kanal-hat-nun-ueber-1000-impressions-und-30-subscriber.html">[Persönliches] Mein YouTube Kanal hat nun über 1000 Impressions und 30 Subscriber</a>
5238
</div>~<div class="snippet">
53-
<a href="2020-08-08-persoenliches-wie-wichtig-ist-es-einen-me-day-zu-haben.html">Wie wichtig ist es einen Me Day zu haben?</a>
39+
<a href="2020-08-08-persoenliches-wie-wichtig-ist-es-einen-me-day-zu-haben.html">Wie wichtig ist es einen &#8220;Me Day&#8221; zu haben?</a>
5440
</div>~<div class="snippet">
5541
<a href="2020-07-25-persoenliches-im-interview-mit-microsoft-zum-thema-surface-duo.html">Ich bin im Interview mit Microsoft zum Thema Surface Duo</a>
5642
</div>~<div class="snippet">
@@ -68,13 +54,13 @@ <h1>Tobias Scholze | The Stuttering Nerd</h1>
6854
</div>~<div class="snippet">
6955
<a href="2020-01-18-persoenlich-habe-nun-mein-eigenes-podcast-experiment.html">Ich habe nun mein eigenes Podcast Experiment gestartet</a>
7056
</div>~<div class="snippet">
71-
<a href="2019-11-30-projekt-rtsd-road-to-surface-duo.html">Neues Projekt: #rTsd Road to Surface Duo</a>
57+
<a href="2019-11-30-projekt-rtsd-road-to-surface-duo.html">Neues Projekt: #rTsd &#8211; Road to Surface Duo</a>
7258
</div>~<div class="snippet">
73-
<a href="2019-10-26-azure-sphere-hackster-io-contest-ping-for-pi.html">Azure Sphere Hackster.io Contest Ping for Pi</a>
59+
<a href="2019-10-26-azure-sphere-hackster-io-contest-ping-for-pi.html">Azure Sphere Hackster.io Contest &#8220;Ping for Pi&#8221;</a>
7460
</div>~<div class="snippet">
75-
<a href="2019-09-28-xamarin-azure-wir-bauen-uns-glueckliche-nachrichten.html">Mit Xamarin & Azure bauen wir uns glückliche Nachrichten</a>
61+
<a href="2019-09-28-xamarin-azure-wir-bauen-uns-glueckliche-nachrichten.html">Mit Xamarin &#038; Azure bauen wir uns glückliche Nachrichten</a>
7662
</div>~<div class="snippet">
77-
<a href="2019-08-24-azure-sphere-blink-das-erste-mal-wieder-c.html">Azure Sphere Blink Das erste Mal wieder C</a>
63+
<a href="2019-08-24-azure-sphere-blink-das-erste-mal-wieder-c.html">Azure Sphere Blink &#8211; Das erste Mal wieder C</a>
7864
</div>~<div class="snippet">
7965
<a href="2019-08-10-raspberry-pi-mit-dem-enviro-hat-das-raumklima-in-excel-visualisieren.html">Raspberry Pi mit dem Enviro HAT das Raumklima in Excel visualisieren</a>
8066
</div>~<div class="snippet">
@@ -88,37 +74,37 @@ <h1>Tobias Scholze | The Stuttering Nerd</h1>
8874
</div>~<div class="snippet">
8975
<a href="2019-05-11-raspberry-pi-windows-10-iot-core-pimoroni-blinkt.html">Raspberry Pi + Windows 10 IoT Core + Pimoroni Blinkt! = <3</a>
9076
</div>~<div class="snippet">
91-
<a href="2019-04-06-python-flask-twitch-teams-browser.html">Mit Python & Flask] einen Twitch Teams Browser bauen</a>
77+
<a href="2019-04-06-python-flask-twitch-teams-browser.html">Mit Python &#038; Flask] einen Twitch Teams Browser bauen</a>
9278
</div>~<div class="snippet">
9379
<a href="2019-03-30-python-twitch-team-zu-markdown-converter.html">Twitch Team zu Markdown Converter in Python</a>
9480
</div>~<div class="snippet">
9581
<a href="2019-01-19-java-einfaches-arbeiten-mit-konsolenargumenten.html">[Java] Einfaches arbeiten mit hübschen Konsolenargumenten</a>
9682
</div>~<div class="snippet">
97-
<a href="2019-01-12-google-sheets-python-sensordaten-mit-graphen-visualisieren.html">Mit Google Sheets & Python Sensordaten mit Graphen visualisieren</a>
83+
<a href="2019-01-12-google-sheets-python-sensordaten-mit-graphen-visualisieren.html">Mit Google Sheets &#038; Python Sensordaten mit Graphen visualisieren</a>
9884
</div>~<div class="snippet">
99-
<a href="2018-05-03-google-assistant-firebase-function-database-fahrtrichtung-von-tobot-via-stimme-steuern.html">Mit Google Assistant & Firebase die Fahrtrichtung von ToboT via Stimme steuern</a>
85+
<a href="2018-05-03-google-assistant-firebase-function-database-fahrtrichtung-von-tobot-via-stimme-steuern.html">Mit Google Assistant &#038; Firebase die Fahrtrichtung von ToboT via Stimme steuern</a>
10086
</div>~<div class="snippet">
10187
<a href="2018-04-04-android-things-der-anfang-von-tobot.html">Der Anfang von ToboT mit Android Things</a>
10288
</div>~<div class="snippet">
10389
<a href="2018-01-02-android-google-firebase-cloud-messaging-pager-mit-android-things.html">Google Firebase Cloud Messaging Pager mit Android Things</a>
10490
</div>~<div class="snippet">
10591
<a href="2017-08-14-mitdabei-gastbeitrag-auf-microsoft-com-o.html">#mitdabei Gastbeitrag auf microsoft.com \o/</a>
10692
</div>~<div class="snippet">
107-
<a href="2016-09-16-ein-tag-in-der-zukunft-bmw-i3-hololense-und-dem-arbeitsplatz-4-0.html">Ein Tag in der Zukunft BMW i3, HoloLens und dem Arbeitsplatz 4.0</a>
93+
<a href="2016-09-16-ein-tag-in-der-zukunft-bmw-i3-hololense-und-dem-arbeitsplatz-4-0.html">Ein Tag in der Zukunft &#8211; BMW i3, HoloLens und dem Arbeitsplatz 4.0</a>
10894
</div>~<div class="snippet">
10995
<a href="2016-07-15-bash-alle-freien-microsoft-ebooks-auf-einmal-laden.html">Bash: Alle freien Microsoft eBooks auf einmal laden</a>
11096
</div>~<div class="snippet">
11197
<a href="2016-07-02-swift-microsoft-cognitive-services-computer-vision-ausprobiert.html">Swift: Microsoft Cognitive Services Computed Vision ausprobiert</a>
11298
</div>~<div class="snippet">
11399
<a href="2015-10-13-windows-10-iot-core-via-c-herunterfahren.html">Windows 10 IoT Core via C# herunterfahren</a>
114100
</div>~<div class="snippet">
115-
<a href="2015-08-12-windows-10-iot-core-ist-offiziell-fertig-hoffentlich-nicht.html">Windows 10 IoT Core ist offiziell fertig hoffentlich nicht!</a>
101+
<a href="2015-08-12-windows-10-iot-core-ist-offiziell-fertig-hoffentlich-nicht.html">Windows 10 IoT Core ist offiziell fertig &#8211; hoffentlich nicht!</a>
116102
</div>~<div class="snippet">
117103
<a href="2015-08-07-microsoft-windows-10-iot-core-ist-noch-nicht-als-digital-signage-geeignet.html">Microsoft Windows 10 IoT Core ist noch nicht als Digital Signage geeignet</a>
118104
</div>~<div class="snippet">
119105
<a href="2015-08-06-ubersicht-windows-10-iot-core-kompatibler-wifi-und-bluetooth-dongle.html">Übersicht Windows 10 IoT Core kompatibler Wifi- und Bluetooth-Dongle</a>
120106
</div>~<div class="snippet">
121-
<a href="2015-08-02-das-windows-iot-technet-forum-hat-ein-spam-problem-und-niemand-interessiert-es.html">Das Windows IoT Technet Forum hat ein Spam Problem und niemand interessiert es</a>
107+
<a href="2015-08-02-das-windows-iot-technet-forum-hat-ein-spam-problem-und-niemand-interessiert-es.html">Das Windows IoT Technet Forum hat ein Spam Problem &#8211; und niemand interessiert es</a>
122108
</div>~<div class="snippet">
123109
<a href="2015-07-19-windows-10-iot-core-unter-os-x-auf-einer-sd-karte-installieren.html">Windows 10 IoT Core unter OS X auf einer SD Karte installieren</a>
124110
</div>~<div class="snippet">

src/main/kotlin/io/github/tscholze/kotlog/Generator.kt

Lines changed: 24 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,15 @@ import kotlin.io.path.writeText
3131
* Possible CLI arguments:
3232
* - `-c 'My awesome title'`: Creates a new blog post
3333
* - `-y beYqB6QXQuY`: Creates a YouTube post
34-
* - `-g`: Generates html output
35-
* - `-p`: Publish aka pushes changes to remote
34+
* - `-g` : Generates html output
35+
* - `-p` : Publish aka pushes changes to remote
36+
* - `-co`: To publish output files
3637
*/
3738
class Kotlog(args: Array<String>, configuration: BlogConfiguration) {
3839
companion object {
3940
// MARK: - Internal constants -
4041

41-
internal const val DEFAULT_DATE_PATTERN = "yyyy-MM-dd"
42+
internal const val DATE_PATTERN = "yyyy-MM-dd"
4243
internal const val MISSING_TEMPLATE_WARNING = "Template not found."
4344
internal const val MISSING_FRONT_MATTER_TITLE_WARNING = "MISSING_TEMPLATE_WARNING"
4445

@@ -48,13 +49,16 @@ class Kotlog(args: Array<String>, configuration: BlogConfiguration) {
4849
private const val RELATIVE_STYLES_PATH = "__styles"
4950
private const val RELATIVE_OUTPUT_PATH = "__output"
5051
private const val RELATIVE_TEMPLATES_PATH = "__templates"
51-
private const val DEFAULT_POST_TEMPLATE_NAME = "post.html"
52-
private const val DEFAULT_INDEX_TEMPLATE_NAME = "index.html"
53-
private const val DEFAULT_SNIPPET_TEMPLATE_NAME = "snippet.html"
54-
private const val DEFAULT_COMPONENT_YOUTUBE_VIDEO_TEMPLATE_NAME = "component_youtube_content.html"
55-
private const val DEFAULT_MARKDOWN_POST_TEMPLATE_NAME = "post.md"
56-
private const val DEFAULT_JSON_OUTPUT_FILENAME = "posts.json"
57-
private const val DEFAULT_INDEX_OUTPUT_FILENAME = "index.html"
52+
53+
private const val POST_TEMPLATE_FILENAME = "post.html"
54+
private const val INDEX_TEMPLATE_FILENAME = "index.html"
55+
private const val SNIPPET_TEMPLATE_FILENAME = "snippet.html"
56+
private const val COMPONENT_YOUTUBE_VIDEO_TEMPLATE_FILENAME = "component_youtube_content.html"
57+
private const val JSON_OUTPUT_FILENAME = "posts.json"
58+
private const val INDEX_OUTPUT_FILENAME = "index.html"
59+
private const val MARKDOWN_POST_TEMPLATE_FILENAME = "post.md"
60+
61+
private val REQUIRED_FOLDERS = listOf(RELATIVE_TEMPLATES_PATH, RELATIVE_STYLES_PATH)
5862
private val EMBEDDED_FILENAMES = listOf("style.css","apple-touch-icon.png","favicon.ico", "icon.svg")
5963
}
6064

@@ -182,8 +186,8 @@ class Kotlog(args: Array<String>, configuration: BlogConfiguration) {
182186
// MARK: - Generators -
183187

184188
private fun generateMarkdownPost(title: String, content: String? = null) {
185-
val template = readFromTemplates(DEFAULT_MARKDOWN_POST_TEMPLATE_NAME)
186-
val dateString = SimpleDateFormat(DEFAULT_DATE_PATTERN).format(Date())
189+
val template = readFromTemplates(MARKDOWN_POST_TEMPLATE_FILENAME)
190+
val dateString = SimpleDateFormat(DATE_PATTERN).format(Date())
187191
val filename = "$dateString-${title.toSlug()}.md"
188192
val markdown = template
189193
.replace("{{title}}", title)
@@ -250,18 +254,18 @@ class Kotlog(args: Array<String>, configuration: BlogConfiguration) {
250254
.reversed()
251255
.joinToString("~") { inflateSnippetTemplate(it) }
252256

253-
val html = readFromTemplates(DEFAULT_INDEX_TEMPLATE_NAME)
257+
val html = readFromTemplates(INDEX_TEMPLATE_FILENAME)
254258
.replace("{{title}}", configuration.titleText)
255259
.replace("{{content}}", content)
256260
.replace("{{archived_content}}", archivedContent)
257261

258262
// Write file
259-
writeToOutput(DEFAULT_INDEX_OUTPUT_FILENAME, html)
263+
writeToOutput(INDEX_OUTPUT_FILENAME, html)
260264
}
261265

262266
private fun generateJsonFeed(configurations: List<SnippetConfiguration>) {
263267
val json = Json.encodeToString(configurations)
264-
writeToOutput(DEFAULT_JSON_OUTPUT_FILENAME, json)
268+
writeToOutput(JSON_OUTPUT_FILENAME, json)
265269
}
266270

267271
private fun embedStyling() {
@@ -274,7 +278,6 @@ class Kotlog(args: Array<String>, configuration: BlogConfiguration) {
274278
private fun printGreeting() {
275279
println("")
276280
println("Welcome to Kotlog <3")
277-
println("")
278281
}
279282

280283
private fun printHelp() {
@@ -322,19 +325,19 @@ class Kotlog(args: Array<String>, configuration: BlogConfiguration) {
322325
// MARK: - Inflaters -
323326

324327
private fun inflateSnippetTemplate(configuration: SnippetConfiguration): String {
325-
return readFromTemplates(DEFAULT_SNIPPET_TEMPLATE_NAME)
328+
return readFromTemplates(SNIPPET_TEMPLATE_FILENAME)
326329
.replace("{{title}}", configuration.title)
327330
.replace("{{relative_url}}", configuration.relativeUrl)
328331
}
329332

330333
private fun inflatePostTemplate(configuration: PostConfiguration): String {
331-
return readFromTemplates(DEFAULT_POST_TEMPLATE_NAME)
334+
return readFromTemplates(POST_TEMPLATE_FILENAME)
332335
.replace("{{title}}", configuration.title)
333336
.replace("{{content}}", configuration.innerHtml)
334337
}
335338

336339
private fun inflateComponentYouTubeContent(configuration: YouTubeComponentConfiguration): String {
337-
return readFromTemplates(DEFAULT_COMPONENT_YOUTUBE_VIDEO_TEMPLATE_NAME)
340+
return readFromTemplates(COMPONENT_YOUTUBE_VIDEO_TEMPLATE_FILENAME)
338341
.replace("{{title}}", configuration.title)
339342
.replace("{{youtube_url}}", configuration.videoUrl)
340343
.replace("{{embed_url}}", configuration.embedUrl)
@@ -385,7 +388,7 @@ class Kotlog(args: Array<String>, configuration: BlogConfiguration) {
385388
// MARK: - Git -
386389

387390
private fun pushToRemote() {
388-
val message = "Content update ${SimpleDateFormat(DEFAULT_DATE_PATTERN).format(Date())}"
391+
val message = "Content update ${SimpleDateFormat(DATE_PATTERN).format(Date())}"
389392
shellRun {
390393
git.commitAllChanges(message)
391394
git.push("origin", "main")
@@ -399,7 +402,7 @@ class Kotlog(args: Array<String>, configuration: BlogConfiguration) {
399402
var isValid = true
400403

401404
// Check if folders that must have files in it exists.
402-
listOf(RELATIVE_TEMPLATES_PATH, RELATIVE_STYLES_PATH)
405+
REQUIRED_FOLDERS
403406
.forEach {
404407
val file = File(it)
405408
if (!file.exists() || !file.isDirectory || file.listFiles().isEmpty()) {

src/main/kotlin/io/github/tscholze/kotlog/models/Models.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ class PostConfiguration(
8282
}
8383
val date = LocalDate.parse(
8484
dateString,
85-
DateTimeFormatter.ofPattern(Kotlog.DEFAULT_DATE_PATTERN)
85+
DateTimeFormatter.ofPattern(Kotlog.DATE_PATTERN)
8686
)
8787

8888
// Generate inner html string

0 commit comments

Comments
 (0)