Skip to content

Commit

Permalink
Merge pull request #329 from tayloraswift/add-assets
Browse files Browse the repository at this point in the history
Add assets
  • Loading branch information
tayloraswift authored Aug 29, 2024
2 parents 3e89894 + 736982f commit b9230cb
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 18 deletions.
1 change: 0 additions & 1 deletion Assets/css/Div.More.css.map

This file was deleted.

1 change: 0 additions & 1 deletion Assets/css/Section.Introduction.css.map

This file was deleted.

16 changes: 7 additions & 9 deletions Guides/docs.docc/Quickstart.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@ Today, there are two main ways to install Unidoc — building it from source or

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

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


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

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

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


> Important:
> 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`.

## 3. Launching a `mongod` instance

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.
Expand All @@ -63,14 +59,16 @@ Please note that this will start a Docker container that runs continuously in th

## 3. Running `unidoc preview`

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:
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:

```bash
unidoc preview
```

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

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.

@Image(source: "Start page.png", alt: "Start page") {
> The `unidoc preview` start page.
}
Expand Down
2 changes: 1 addition & 1 deletion Guides/docs.docc/local/unidoc-from-source.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ mkdir -p ~/unidoc/bin
git clone https://github.com/tayloraswift/swift-unidoc
cd swift-unidoc
swift build -c release --product unidoc
mv .build/release/unidoc ~/unidoc/bin/unidoc
mv .build/release/unidoc /usr/local/bin/unidoc
2 changes: 1 addition & 1 deletion Package.resolved
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"originHash" : "001c135407cac40e7a16c09d015f19f41fc74c973a73e78466929b828ae4288b",
"originHash" : "3ca1cc079c7ca5e3e9db0253fcca6ac1063c31ea5b3653bae0183ba85697f0d3",
"pins" : [
{
"identity" : "indexstore-db",
Expand Down
1 change: 1 addition & 0 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ let package:Package = .init(
dependencies: [
.target(name: "System_ArgumentParser"),
.target(name: "S3Client"),
.target(name: "UnidocAssets_System"),
]),


Expand Down
31 changes: 26 additions & 5 deletions Sources/unidoc-publish/Main.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import NIOSSL
import S3
import S3Client
import System
import Unidoc
import UnidocAssets_System

struct Main
{
Expand Down Expand Up @@ -58,12 +60,31 @@ extension AWS.S3.Client

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

try SystemProcess.init(command: "tar",
// Sadly, tar on macOS doesn’t support this option.
// "--use-compress-program='gzip -9'",
"-C", "\(release)",
var arguments:[String] = [
"-czf", "\(archive)",
name)()
"-C", ".",
]

let assets:FilePath.Directory = "Assets"
for asset:Unidoc.Asset in [
.main_css,
.main_css_map,
.main_js,
.main_js_map,
.literata45_woff2,
.literata47_woff2,
.literata75_woff2,
.literata77_woff2
]
{
arguments.append("\(assets.path.appending(asset.source))")
}
// This needs to come after the `.` location, as each `-C` is relative to the last.
arguments.append("-C")
arguments.append("\(release)")
arguments.append(name)

try SystemProcess.init(command: "tar", arguments: arguments, echo: true)()
let file:[UInt8] = try archive.read()

try await self.connect
Expand Down

0 comments on commit b9230cb

Please sign in to comment.