Skip to content

Commit b9230cb

Browse files
authored
Merge pull request #329 from tayloraswift/add-assets
Add assets
2 parents 3e89894 + 736982f commit b9230cb

File tree

7 files changed

+36
-18
lines changed

7 files changed

+36
-18
lines changed

Assets/css/Div.More.css.map

Lines changed: 0 additions & 1 deletion
This file was deleted.

Assets/css/Section.Introduction.css.map

Lines changed: 0 additions & 1 deletion
This file was deleted.

Guides/docs.docc/Quickstart.md

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,13 @@ Today, there are two main ways to install Unidoc — building it from source or
2424

2525
Pre-built binaries are available for a limited set of platforms.
2626

27-
| Platform | Download |
27+
| Platform | String |
2828
|----------|----------|
29-
| macOS | [`macOS-ARM64/unidoc.tar.gz`](https://static.swiftinit.org/unidoc/0.19.0/macOS-ARM64/unidoc.tar.gz) |
30-
| Linux | [`Linux-X64/unidoc.tar.gz`](https://static.swiftinit.org/unidoc/0.19.0/Linux-X64/unidoc.tar.gz) |
29+
| macOS | `macOS-ARM64` |
30+
| Linux | `Linux-X64` |
3131

3232

33-
You can download and install the binary in your home directory like this:
33+
You can download and install the binary under `/usr/local/bin` like this:
3434

3535
@Code(file: unidoc-install.sh, title: unidoc-install.sh)
3636

@@ -42,10 +42,6 @@ Unidoc is an ordinary SwiftPM executable product. You can build it for your macO
4242
@Code(file: unidoc-from-source.sh, title: unidoc-from-source.sh)
4343

4444

45-
> Important:
46-
> The rest of this guide assumes you have installed Unidoc somewhere on your macOS host that is visible in your `PATH` and allows you to invoke it as `unidoc`.
47-
48-
4945
## 3. Launching a `mongod` instance
5046

5147
Unidoc can configure a `mongod` instance for you through the `unidoc init` command. This tool takes a directory path as an argument, which it uses to persist the state of the database. In the example below, we will create the documentation database in a directory named `unidoc` in your home directory.
@@ -63,14 +59,16 @@ Please note that this will start a Docker container that runs continuously in th
6359

6460
## 3. Running `unidoc preview`
6561

66-
The `unidoc preview` tool is a simple web server that links and serves documentation for local Swift packages. Run it directly from your macOS host like this:
62+
The `unidoc preview` tool is a simple web server that links and serves documentation for local Swift packages. Run it directly from the host like this:
6763

6864
```bash
6965
unidoc preview
7066
```
7167

7268
The `unidoc preview` tool will start a web server on [`http://localhost:8080`](http://localhost:8080).
7369

70+
Please note that to serve the necessary CSS and JavaScript the server expects to find the `Assets` directory in the current working directory. These resources are included in the `unidoc.tar.gz` archives, and if built from source, they are also available in the `swift-unidoc` repository.
71+
7472
@Image(source: "Start page.png", alt: "Start page") {
7573
> The `unidoc preview` start page.
7674
}

Guides/docs.docc/local/unidoc-from-source.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ mkdir -p ~/unidoc/bin
22
git clone https://github.com/tayloraswift/swift-unidoc
33
cd swift-unidoc
44
swift build -c release --product unidoc
5-
mv .build/release/unidoc ~/unidoc/bin/unidoc
5+
mv .build/release/unidoc /usr/local/bin/unidoc

Package.resolved

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Package.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ let package:Package = .init(
139139
dependencies: [
140140
.target(name: "System_ArgumentParser"),
141141
.target(name: "S3Client"),
142+
.target(name: "UnidocAssets_System"),
142143
]),
143144

144145

Sources/unidoc-publish/Main.swift

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ import NIOSSL
66
import S3
77
import S3Client
88
import System
9+
import Unidoc
10+
import UnidocAssets_System
911

1012
struct Main
1113
{
@@ -58,12 +60,31 @@ extension AWS.S3.Client
5860

5961
print("Compressing \(name)...")
6062

61-
try SystemProcess.init(command: "tar",
62-
// Sadly, tar on macOS doesn’t support this option.
63-
// "--use-compress-program='gzip -9'",
64-
"-C", "\(release)",
63+
var arguments:[String] = [
6564
"-czf", "\(archive)",
66-
name)()
65+
"-C", ".",
66+
]
67+
68+
let assets:FilePath.Directory = "Assets"
69+
for asset:Unidoc.Asset in [
70+
.main_css,
71+
.main_css_map,
72+
.main_js,
73+
.main_js_map,
74+
.literata45_woff2,
75+
.literata47_woff2,
76+
.literata75_woff2,
77+
.literata77_woff2
78+
]
79+
{
80+
arguments.append("\(assets.path.appending(asset.source))")
81+
}
82+
// This needs to come after the `.` location, as each `-C` is relative to the last.
83+
arguments.append("-C")
84+
arguments.append("\(release)")
85+
arguments.append(name)
86+
87+
try SystemProcess.init(command: "tar", arguments: arguments, echo: true)()
6788
let file:[UInt8] = try archive.read()
6889

6990
try await self.connect

0 commit comments

Comments
 (0)