Skip to content

Commit

Permalink
refactor: code structure & design
Browse files Browse the repository at this point in the history
  • Loading branch information
novalagung committed Nov 27, 2024
1 parent bd528cc commit 46f1ade
Show file tree
Hide file tree
Showing 11 changed files with 92 additions and 48 deletions.
15 changes: 5 additions & 10 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,8 @@ jobs:
run: |
rm -f README.md
mv content/* .
mv etc/cover_small.jpg .
mv etc/cover_square.png .
mv etc/cover.jpg .
mv etc/style-custom.css .
mv book.json etc/
mv etc/main.go .
mv etc/robots.txt .
mv etc/script-gitbook-plugin-disqus.js .
npm install -g gitbook-cli
gitbook install
cd ~/.gitbook/versions/3.2.3 && npm i npm@5
Expand Down Expand Up @@ -73,12 +68,12 @@ jobs:
run: |
rm -f README.md
mv content/* .
mv etc/cover_small.jpg .
mv etc/cover_square.png .
mv etc/cover.jpg .
mv etc/main.go .
go run main.go -mode=ebook -adjustment=pre
rm -f book.json
gitbook install
cd ~/.gitbook/versions/3.2.3 && npm i npm@5
cd ${{ github.workspace }}
go run main.go -mode=ebook -adjustment=pre
mkdir _book/
- name: 'Generating ebook in pdf'
run: gitbook pdf ./ ./_book/dasarpemrogramangolang.pdf
Expand Down
2 changes: 1 addition & 1 deletion content/2-instalasi-golang.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# A.2. Instalasi Golang (Stable & Unstable)
# A.2. Instalasi Golang

Hal pertama yang perlu dilakukan sebelum bisa menggunakan Go adalah meng-*install*-nya terlebih dahulu. Panduan instalasi sebenarnya sudah disediakan di situs resmi Go [http://golang.org/doc/install#install](http://golang.org/doc/install#install).

Expand Down
2 changes: 1 addition & 1 deletion content/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

* A. Pemrograman Go Dasar
* [A.1. Belajar Golang](1-berkenalan-dengan-golang.md)
* [A.2. Instalasi Golang (Stable & Unstable)](2-instalasi-golang.md)
* [A.2. Instalasi Golang](2-instalasi-golang.md)
* [A.3. Setup Go Modules](A-setup-go-project-dengan-go-modules.md)
* [A.4. Setup GOPATH dan Workspace](A-gopath-dan-workspace.md)
* [A.5. Instalasi Editor](A-instalasi-editor.md)
Expand Down
9 changes: 9 additions & 0 deletions etc/book.json → content/book.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,15 @@
"meta",
"sitemap"
],
"styles": {
"website": "style-website-v2.css"
},
"pdf": {
"margin": {
"left": 10,
"right": 10
}
},
"pluginsConfig": {
"disqus": {
"shortName": "dasarpemrogramangolang"
Expand Down
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes.
103 changes: 75 additions & 28 deletions etc/style-custom.css → content/style-website-v2.css
Original file line number Diff line number Diff line change
Expand Up @@ -32,23 +32,10 @@ body .book.font-family-1, .book-summary {
}

.page-inner {
max-width: fit-content;
max-width: none;
padding: 20px 100px 40px 100px;
}

/* disable word wrap at left sidebar */
.book-summary ul.summary li a, .book-summary ul.summary li span {
text-overflow: initial;
white-space: normal;
line-height: 1.4em;
padding: 9px 15px;
}

/* sidebar background */
.book-summary {
background-color: #ffffff;
}

/* sidebar ads animation */
/* .book-summary .summary > li:nth-child(8) a {
color: white;
Expand Down Expand Up @@ -81,18 +68,64 @@ body .book.font-family-1, .book-summary {
background: hsla(0,0%,53%,.1);
}

/* sidebar active link */
.book-summary li.active>a:before {
content: " ";
/* sidebar background */
.book-summary {
background-color: #ffffff;
}

/* sidebar items */
.book-summary ul.summary li a, .book-summary ul.summary li span {
text-overflow: initial;
white-space: normal;
line-height: 1.4em;
padding: 9px 10px 9px 6px;
}
.book-summary ul.summary li.chapter {
position: relative;
padding-left: 10px;
padding-right: 10px;
}
.book-summary ul.summary > li.chapter:before {
position: absolute;
right: 0;
top: 0;
bottom: 0;
content: " ";
background-color: #F4F4F5;
width: 2px;
background-color: #008cff;
left: 27px;
top: 39px;
bottom: 0px;
}
.book-summary ul.summary li.chapter span {
font-weight: 600;
}
.book-summary ul.summary li.chapter a {
text-indent: -41px;
padding-left: 51px;
}
.book-summary li.active>a {
.book-summary ul.summary li.chapter a:hover, .book-summary ul.summary li.chapter.active a {
background-color: #F4F4F5;
font-weight: bold;
border-radius: 6px;
text-decoration: none;
}
.book-summary ul.summary li span:before {
content: "📄";
margin-right: 2px;
font-size: 1.2em;
}
.book-summary ul.summary li.divider {
margin: 18px 0 7px;
}

/* docsearch */
#book-doc-search-input {
padding: 5px;
}
#book-doc-search-input .DocSearch-Button {
border-radius: 6px;
background-color: #F4F4F5;
}
#book-doc-search-input .DocSearch-Button:hover {
box-shadow: inset 0 0 0 2px #008cff;
}

/* make the sidebar wider, and adjust the content to match it */
Expand All @@ -106,13 +139,33 @@ body .book.font-family-1, .book-summary {
}
}

.book-header {
border-bottom: 1px solid #ededed;
height: 59px;
padding: 5px 8px 0px;
}

/* hide the header because each post already has it's h1 */
/* also hide the unused navigation buttons (except font settings) */
.book-header > h1,
.book-header > .pull-right:not(.font-settings) {
display: none;
}

/* content */
.markdown-section h1 {
font-weight: 400;
margin-bottom: 0.4em;
}
.markdown-section hr,
.ebook-wrapper hr {
height: 1px !important;
background-color: #e7e9ee !important;
}
.markdown-section blockquote {
font-style: italic;
}

/* hide the "published by gitbook" footer */
.gitbook-link {
visibility: hidden;
Expand Down Expand Up @@ -219,9 +272,3 @@ ins.adsbygoogle {
margin-top: -100px;
}
}

.markdown-section hr,
.ebook-wrapper hr {
height: 1px !important;
background-color: #e7e9ee !important;
}
9 changes: 1 addition & 8 deletions etc/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,21 +170,14 @@ func webbookPostAdjustment() {

// ==== inject github stars button
buttonToFind := `</body>`
buttonReplacement := `<div style="position: fixed; top: 10px; right: 30px; padding: 10px; background-color: rgba(255, 255, 255, 0.7);">
buttonReplacement := `<div style="position: fixed; top: 5px; right: 30px; padding: 10px; background-color: rgba(255, 255, 255, 0.7);">
<a class="github-button" href="https://github.com/sponsors/novalagung" data-color-scheme="no-preference: light; light: light; dark: dark;" data-icon="octicon-heart" data-size="large" aria-label="Sponsor @novalagung on GitHub">Sponsor</a>&nbsp;
<a class="github-button" href="https://github.com/novalagung/dasarpemrogramangolang" data-icon="octicon-star" data-size="large" data-show-count="true" aria-label="Star novalagung/dasarpemrogramangolang on GitHub">Star</a>&nbsp;
<a class="github-button" href="https://github.com/novalagung" data-size="large" aria-label="Follow @novalagung on GitHub">Follow @novalagung</a>
<script async defer src="https://buttons.github.io/buttons.js"></script>
</div>` + buttonToFind
htmlString = strings.ReplaceAll(htmlString, buttonToFind, buttonReplacement)

// ==== inject adjustment css
adjustmentCSSBuf, _ := os.ReadFile("./style-custom.css")
os.WriteFile("./_book/gitbook/style-custom.css", adjustmentCSSBuf, 0644)
adjustmentCSSToFind := `</head>`
adjustmentCSSReplacement := `<link rel="stylesheet" href="gitbook/style-custom.css?v=` + getVersion() + `">` + adjustmentCSSToFind
htmlString = strings.ReplaceAll(htmlString, adjustmentCSSToFind, adjustmentCSSReplacement)

// ==== inject github stars js script
buttonScriptToFind := `</head>`
buttonScriptReplacement := `<script async defer src="https://buttons.github.io/buttons.js"></script>` + buttonScriptToFind
Expand Down

0 comments on commit 46f1ade

Please sign in to comment.