Skip to content

Commit 8fab92a

Browse files
committed
Merge branch 'dev'
2 parents b9518be + 00cd87a commit 8fab92a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+923
-385
lines changed

.github/ISSUE_TEMPLATE/bug_report.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,10 @@ Steps to reproduce the behavior:
3636
3. All configurations you used
3737
4. See error
3838

39+
## Additional information
40+
41+
**The used wiki2book version (or commit-hash)**
42+
43+
**Used output driver (when using `pandoc` output driver: The used pandoc version)**
44+
45+
**Any other useful and/or related information**

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
src/src
33
src/wiki2book
44
wiki2book
5+
wiki2book-*
56
.wiki2book
67
*.exe
78
*.exe~

README.md

Lines changed: 22 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -28,25 +28,26 @@ But wiki2book has exactly this functionality called "projects" as described belo
2828
# Installation
2929

3030
* Arch Linux: AUR package [`wiki2book`](https://aur.archlinux.org/packages/wiki2book).
31-
* Default style and configs can be found in ` /usr/share/wiki2book`.
32-
* Others: See the [build instructions](./src#build-project).
31+
* Default style and configs can be found in `/usr/share/wiki2book`.
32+
* Others: See the [current releases](https://github.com/hauke96/wiki2book/releases) or [build instructions](./src#build-project).
3333

3434
# Usage
3535

36-
Currently only a CLI version of wiki2book exists.
36+
Currently only a CLI (_command line interface_) version of wiki2book exists, so nothing with a GUI.
37+
Wiki2book need a configuration file (s. the [configs](./configs) folder), currently only a German config file exists.
3738

3839
## Preliminaries
3940

4041
You need the following tools and fonts:
4142

4243
1. ImageMagick (to have the `convert` command)
43-
2. Pandoc (to have the `pandoc` command). See notes on pandoc versions 2 and 3 below.
44-
3. *Optional:* DejaVu fonts in `/usr/share/fonts/TTF/DejaVuSans*.ttf`
45-
* The DejaVuSans font is used by the default style in this repo but can be replaced to any other font.
44+
2. *Optional:*
45+
* Pandoc (when using the `pandoc` output driver). See notes on pandoc versions 2 and 3 below.
46+
* DejaVu fonts in `/usr/share/fonts/TTF/DejaVuSans*.ttf` (is used by the default style in this repo but can be replaced to any other font).
4647

4748
## CLI
4849

49-
The current CLI is pretty simple and has three sub-commands:
50+
The CLI contains three sub-commands that generate an EPUB file from different sources (s. below for examples and details on each sub-command):
5051

5152
1. Project: `wiki2book project ./path/to/project.json`
5253
2. Article: `wiki2book article "article name"`
@@ -56,63 +57,12 @@ Use `wiki2book -h` for more information and `wiki2book <command> -h` for informa
5657

5758
### Configuration
5859

59-
Next to the project file (s. below), the application reads technical, project-independent and basic configurations from a JSON file (e.g. the templates to ignore), which can be specified with `--config, -c <file>`.
60-
See [configs/de.json](configs/de.json) for an example and [src/config/config.go](src/config/config.go) for all technical details on each possible value including their defaults.
61-
62-
Some properties can be configured in both, the project and configuration file (such as the Wikipedia URL).
63-
Entries from the project file are used in case a property is given in both files.
64-
65-
Also take a look at the [config.go](src/config/config.go) source file, which contains a lot of documentation on each config entry.
66-
67-
### Project file
68-
69-
When using a project, the above-mentioned `project.json` is a configuration for this project, containing e.g. the title, cover image and list of articles, and may look like this:
70-
71-
```json
72-
{
73-
"metadata": {
74-
"title": "My great book",
75-
"author": "Wikipedia contributors",
76-
"license": "Creative Commons Non-Commercial Share Alike 3.0",
77-
"language": "de-DE",
78-
"date": "2021-12-27"
79-
},
80-
"cache-dir": "./path/to/cache/",
81-
"wikipedia-instance": "de",
82-
"output-file": "my-book.epub",
83-
"output-type": "epub3",
84-
"cover": "cover.png",
85-
"style": "style.css",
86-
"pandoc-data-dir": "./pandoc/data",
87-
"articles": [
88-
"Hamburg",
89-
"Hamburger",
90-
"Pannfisch"
91-
],
92-
"font-files": [
93-
"/path/to/font.ttf",
94-
"/path/to/fontBold.ttf",
95-
"/path/to/fontItalic.ttf"
96-
]
97-
}
98-
```
99-
100-
There are some optional entries:
101-
102-
* `cache-dir` (has the default value `.wiki2book`)
103-
* `output-type` (has the default value `epub2`)
104-
* `font-files`
105-
* `wikipedia-instance` (this value overrides the general configuration (s. above) when given)
106-
107-
#### Use a different Wikipedia instance
108-
109-
Per default, the english wikipedia (`en`) is used.
110-
However, you can change the `wikipedia-instance` entry in your projects or config file (s. above; project entries take precedence over configuration entries).
111-
Notice, that you also have to adjust the list of ignore templates and all other language-specific configurations.
112-
Take a look at the [German config file](configs/de.json) and some [German project files](projects/de/) to get an idea of a switch to a different Wikipedia instance.
60+
See the [config documentation](./doc/configuration.md).
11361

11462
### Pandoc version 2 and 3
11563

64+
_Only relevant when using the `pandoc` output driver._
65+
11666
Pandoc version 2 might internally use CSS3 parameters by default, such as the `gap` property.
11767
This might cause problems on certain eBook readers (e.g. Tolino ones).
11868
To overcome this, pass the argument `--pandoc-data-dir ./pandoc/data` to wiki2book, which uses a template from this repo without such problematic `gap` parameter.
@@ -146,9 +96,18 @@ Use the following command to render the file
14696

14797
`./wiki2book standalone -c configs/de.json -s projects/style.css ./integration-tests/test-real-article-Erde.mediawiki`
14898

149-
# Development
99+
# Contribute
100+
101+
## Issues, bugs, ideas
102+
103+
Feel free to open [a new issue](https://github.com/hauke96/wiki2book/issues/new/choose).
104+
But keep in mind:
105+
This is a hobby-project and my time is limited.
106+
Things with less or no use for me personally will get a lower priority.
107+
108+
## Development
150109

151-
For building, running, testing, etc. take a look at the `src` folder and `src/README.md`.
110+
For building, running, testing, etc. take a look at [`src/README.md`](src/README.md).
152111

153112
# Long-term goals
154113

build.sh

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
#!/bin/bash
22

33
# Get latest tag for this commit
4-
VERSION=$(git describe --tags --abbrev=0)
4+
VERSION=$(grep --color=never "VERSION = " src/main.go | grep --color=never -Po "v[\d\.]+")
55

66
# Some default value
7-
OS=linux
7+
OS=all
88
ARCH=amd64
99

1010
function usage()
1111
{
1212
cat <<EOF
13-
Usage: $0 -a <arch> -o <os> [-f <output-file>]
13+
Usage: $0 -a <arch> -o <os> [-f <output-file>] [-h]
1414
1515
Parameter:
1616
-a Architecture of the system as golang uses them (e.g. amd64, arm64). Default: amd64.
17-
-o Operating system as golang uses them (e.g. windows, linux, darwin). Default: linux.
18-
-f Optional: Output file. If not given, then a filename including the version, arch and os is chosen.
17+
-o Operating system as golang uses them (e.g. windows, linux, darwin). Or use "all" to build for all operating systems. Default: all.
18+
-f Optional: Output file. If not given, then a filename including the version, arch and os is chosen. Will be ignored when operating system is "all".
1919
-h Prints this message.
2020
EOF
2121
}
@@ -25,13 +25,14 @@ function build()
2525
OS=$1
2626
ARCH=$2
2727
OUTPUT=$3
28-
SUFFIX=""
2928

3029
if [[ $OS == "windows" ]]
3130
then
3231
OUTPUT="$OUTPUT.exe"
3332
fi
3433

34+
echo "Build for $OS with $ARCH arch to $(realpath --relative-to=. $OUTPUT)"
35+
3536
# The -ldflags "-s -w" parameter makes the binary smaller by not generating symbol table and debugging information.
3637
GOOS=$OS GOARCH=$ARCH go build -ldflags "-s -w" -o $OUTPUT .
3738
}
@@ -74,9 +75,14 @@ else
7475
OUTPUT=$(realpath "wiki2book-$VERSION-$OS-$ARCH")
7576
fi
7677

77-
echo "Build for $OS with $ARCH arch to $(realpath --relative-to=. $OUTPUT)"
78-
7978
(
8079
cd src
81-
build $OS $ARCH $OUTPUT
80+
if [[ $OS == "all" ]]
81+
then
82+
build "windows" $ARCH $(realpath "wiki2book-$VERSION-windows-$ARCH")
83+
build "linux" $ARCH $(realpath "wiki2book-$VERSION-linux-$ARCH")
84+
build "darwin" $ARCH $(realpath "wiki2book-$VERSION-darwin-$ARCH")
85+
else
86+
build $OS $ARCH $OUTPUT
87+
fi
8288
)

configs/de.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,9 @@
6969
"wikisource",
7070
"wiktionary"
7171
],
72+
"trailing-templates": [
73+
"gesundheitshinweis"
74+
],
7275
"ignored-image-params": [
7376
"alt",
7477
"alternativtext",

doc/README.md

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
This is the documentation of the codebase for *wiki2book*.
22

3-
# Content
3+
## User documentation
44

5-
1. [Structure & Architecture](architecture.md): Description of the overall architecture, layers and packages.
6-
2. [Rendering math](rendering-math.md): Documentation on how to render math code (TeX code) using the Wikipedia API.
7-
3. [Caches](caches.md): This tool uses its own caching infrastructure, this is why and how.
8-
4. [Parsing strategies](parsing.md): Descriptions of the used parsing strategies.
5+
* [Configuration](configuration.md): Documentation of config file, project file and CLI arguments.
6+
7+
## Technical and internal documentation
8+
9+
* [Structure & Architecture](architecture.md): Description of the overall architecture, layers and packages.
10+
* [Rendering math](rendering-math.md): Documentation on how to render math code (TeX code) using the Wikipedia API.
11+
* [Caches](caches.md): This tool uses its own caching infrastructure, this is why and how.
12+
* [Parsing strategies](parsing.md): Descriptions of the used parsing strategies.

0 commit comments

Comments
 (0)