Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
idoyo7 committed Nov 30, 2024
0 parents commit 1e4af22
Show file tree
Hide file tree
Showing 43 changed files with 3,881 additions and 0 deletions.
18 changes: 18 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Node.js 최신 LTS 버전인 18 버전을 사용합니다.
FROM node:18

# 작업 디렉토리를 설정합니다.
WORKDIR /app

# HonKit을 글로벌로 설치합니다.
RUN npm install -g honkit

# 현재 디렉토리의 내용을 컨테이너로 복사합니다.
COPY . /app

# 포트 설정
EXPOSE 4000

# GitBook을 빌드하고 서버를 실행합니다.
CMD ["honkit", "serve"]

2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Introduction

9 changes: 9 additions & 0 deletions SUMMARY.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Summary

* [Introduction](README.md)
* [제1장: 새로운 시작](chapter1.md)

* 게시글
* [제1장: 새로운 시작](posts/chapter1.md)
* [제2장: 다음 단계](posts/chapter2.md)
* [제3장: 심화 과정](posts/chapter3.md)
18 changes: 18 additions & 0 deletions _book/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Node.js 최신 LTS 버전인 18 버전을 사용합니다.
FROM node:18

# 작업 디렉토리를 설정합니다.
WORKDIR /app

# HonKit을 글로벌로 설치합니다.
RUN npm install -g honkit

# 현재 디렉토리의 내용을 컨테이너로 복사합니다.
COPY . /app

# 포트 설정
EXPOSE 4000

# GitBook을 빌드하고 서버를 실행합니다.
CMD ["honkit", "serve"]

3 changes: 3 additions & 0 deletions _book/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#/bin/bash
docker build -t my-gitbook .

238 changes: 238 additions & 0 deletions _book/gitbook/@honkit/honkit-plugin-fontsettings/fontsettings.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,238 @@
require(["gitbook", "jquery"], (gitbook, $) => {
// Configuration
const MAX_SIZE = 4;
const MIN_SIZE = 0;
let BUTTON_ID;

// Current fontsettings state
let fontState;

// Default themes
let THEMES = [
{
config: "white",
text: "White",
id: 0
},
{
config: "sepia",
text: "Sepia",
id: 1
},
{
config: "night",
text: "Night",
id: 2
}
];

// Default font families
let FAMILIES = [
{
config: "serif",
text: "Serif",
id: 0
},
{
config: "sans",
text: "Sans",
id: 1
}
];

// Return configured themes
function getThemes() {
return THEMES;
}

// Modify configured themes
function setThemes(themes) {
THEMES = themes;
updateButtons();
}

// Return configured font families
function getFamilies() {
return FAMILIES;
}

// Modify configured font families
function setFamilies(families) {
FAMILIES = families;
updateButtons();
}

// Save current font settings
function saveFontSettings() {
gitbook.storage.set("fontState", fontState);
update();
}

// Increase font size
function enlargeFontSize(e) {
e.preventDefault();
if (fontState.size >= MAX_SIZE) return;

fontState.size++;
saveFontSettings();
}

// Decrease font size
function reduceFontSize(e) {
e.preventDefault();
if (fontState.size <= MIN_SIZE) return;

fontState.size--;
saveFontSettings();
}

// Change font family
function changeFontFamily(configName, e) {
if (e && e instanceof Event) {
e.preventDefault();
}

const familyId = getFontFamilyId(configName);
fontState.family = familyId;
saveFontSettings();
}

// Change type of color theme
function changeColorTheme(configName, e) {
if (e && e instanceof Event) {
e.preventDefault();
}

const $book = gitbook.state.$book;

// Remove currently applied color theme
if (fontState.theme !== 0) $book.removeClass(`color-theme-${fontState.theme}`);

// Set new color theme
const themeId = getThemeId(configName);
fontState.theme = themeId;
if (fontState.theme !== 0) $book.addClass(`color-theme-${fontState.theme}`);

saveFontSettings();
}

// Return the correct id for a font-family config key
// Default to first font-family
function getFontFamilyId(configName) {
// Search for plugin configured font family
const configFamily = $.grep(FAMILIES, (family) => {
return family.config == configName;
})[0];

// Fallback to default font family
return (configFamily && configFamily.id) || 0;
}

// Return the correct id for a theme config key
// Default to first theme
function getThemeId(configName) {
// Search for plugin configured theme
const configTheme = $.grep(THEMES, (theme) => {
return theme.config == configName;
})[0];

// Fallback to default theme
return (configTheme && configTheme.id) || 0;
}

function update() {
const $book = gitbook.state.$book;

$(".font-settings .font-family-list li").removeClass("active");
$(`.font-settings .font-family-list li:nth-child(${fontState.family + 1})`).addClass("active");

$book[0].className = $book[0].className.replace(/\bfont-\S+/g, "");
$book.addClass(`font-size-${fontState.size}`);
$book.addClass(`font-family-${fontState.family}`);

if (fontState.theme !== 0) {
$book[0].className = $book[0].className.replace(/\bcolor-theme-\S+/g, "");
$book.addClass(`color-theme-${fontState.theme}`);
}
}

function init(config) {
// Search for plugin configured font family
const configFamily = getFontFamilyId(config.family);
const configTheme = getThemeId(config.theme);

// Instantiate font state object
fontState = gitbook.storage.get("fontState", {
size: config.size || 2,
family: configFamily,
theme: configTheme
});

update();
}

function updateButtons() {
// Remove existing fontsettings buttons
if (BUTTON_ID) {
gitbook.toolbar.removeButton(BUTTON_ID);
}

// Create buttons in toolbar
BUTTON_ID = gitbook.toolbar.createButton({
icon: "fa fa-font",
label: "Font Settings",
className: "font-settings",
dropdown: [
[
{
text: "A",
className: "font-reduce",
onClick: reduceFontSize
},
{
text: "A",
className: "font-enlarge",
onClick: enlargeFontSize
}
],
$.map(FAMILIES, (family) => {
family.onClick = function (e) {
return changeFontFamily(family.config, e);
};

return family;
}),
$.map(THEMES, (theme) => {
theme.onClick = function (e) {
return changeColorTheme(theme.config, e);
};

return theme;
})
]
});
}

// Init configuration at start
gitbook.events.bind("start", (e, config) => {
const opts = config.fontsettings;

// Generate buttons at start
updateButtons();

// Init current settings
init(opts);
});

// Expose API
gitbook.fontsettings = {
enlargeFontSize: enlargeFontSize,
reduceFontSize: reduceFontSize,
setTheme: changeColorTheme,
setFamily: changeFontFamily,
getThemes: getThemes,
setThemes: setThemes,
getFamilies: getFamilies,
setFamilies: setFamilies
};
});
Loading

0 comments on commit 1e4af22

Please sign in to comment.