Skip to content

Commit

Permalink
link/redirect to content moved to try.perm.pub
Browse files Browse the repository at this point in the history
  • Loading branch information
castedo committed Oct 25, 2023
1 parent bd76a0d commit 564a891
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 174 deletions.
78 changes: 4 additions & 74 deletions docs/basecast/containers.md
Original file line number Diff line number Diff line change
@@ -1,74 +1,4 @@
# Containers

Running `basecast` inside an [OCI container](https://opencontainers.org/),
often known as a Docker container, avoids many typical installation problems.
Containers can be run using `podman` or `docker`,
with `podman` being the recommended option.
However, replacing `podman` with `docker` will _probably_ still work.
Podman is a superior drop-in replacement to the `docker` tool.

### Step One

The first step is to install `podman` if it is not already installed.

[Get Started with Podman](https://podman.io/get-started){ .md-button .md-button--primary target='_blank' }

### Step Two

Define a shell function named `basecast` to run the container image
[`docker.io/castedo/basecast`](https://hub.docker.com/r/castedo/basecast/tags).

In the bash shell, this is achieved with the following lines:

```bash
basecast() {
podman run --rm -v=$PWD:/mnt -w=/mnt docker.io/castedo/basecast basecast "$@"
}
```

You can manually enter these lines at the bash command line or copy them into an
initialization file (e.g., `.bashrc`).

!!! warning

Basecast can ONLY access relative file paths below the current directory
when run inside a container via the above bash function.


### Step Three

After defining the shell function mentioned above, you can test it by simply typing the shell command
as if `basecast` were installed locally:

```bash
basecast
```

The first execution of this function will trigger a one-time download of the container image (almost 1GB!),
and then `basecast` will display the [command line](usage.md) help.

If you are running with SELinux, you may need to insert `--security-opt label=disable`
after `podman run`.

NOTE: Running this shell command will share the local current working directory with the
container. Therefore, only relative paths to files under the current working directory
will work.

### Step Four (Optional)

When generating HTML previews of a baseprint, it can be convenient to run a local web
server that automatically refreshes the preview web page when it is regenerated.

The Basecast container image includes such a web server.
It can be used by setting up a second shell function similar to the `basecast` function in step two.

```bash
live-basecast() {
podman run --rm -v=.:/mnt -w=/mnt -p=8080:8080 -it \
docker.io/castedo/basecast bash -c "live-server site & basecast -o=site $*"
}
```

### Done

[Learn how to use `basecast`](usage.md){ .md-button }
---
template: redirect.html
location: "https://try.perm.pub/howto/basecast_container/"
---
53 changes: 5 additions & 48 deletions docs/basecast/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,50 +13,9 @@ Basecast can be run in the cloud (GitHub) or from the command line.

## Run in the cloud (GitHub)

A "BasecastBot" repository will automatically generate and deploy a baseprint preview to
[GitHub Pages](https://docs.github.com/en/pages)
when changes are made to document source files in the repository.
An example of a baseprint preview automatically generated by a BasecastBot repository can be found at
[castedo.github.io/basecastbot-example/](https://castedo.github.io/basecastbot-example/).
Start the try.perm.pub tutorial:


### GitHub Step 1:

To quickly get started, use
[basecastbot-example](https://github.com/castedo/basecastbot-example/)
as a template to create a BasecastBot repository for your new document.

[Create a BasecastBot repository](
https://github.com/new?template_owner=castedo&template_name=basecastbot-example
){ .md-button .md-button--primary target='_blank' }

For alternative options, such as when a repository already exists, visit the
[Basecast build action](https://github.com/castedo/basecast-build-action).


### GitHub Step 2:

Follow [these substeps to publish to Pages](
https://docs.github.com/en/pages/getting-started-with-github-pages/configuring-a-publishing-source-for-your-github-pages-site#publishing-with-a-custom-github-actions-workflow
):

- On GitHub, navigate to your site's repository.
- Under your repository name, click Settings. If you cannot see the "Settings" tab, select the dropdown menu, then click Settings.
- In the "Code and automation" section of the sidebar, click Pages.
- Under "Build and deployment", under "Source", select GitHub Actions.

Since the [basecastbot-example](https://github.com/castedo/basecastbot-example/)
template includes a `.github/workflows/pages-deploy.yaml` workflow,
your new BasecastBot repository will also have this workflow.


### GitHub Step 3:

Edit and commit a source file into the repository (e.g., `pandocin.yaml`).
This will automatically trigger a build and deploy.
Once the deploy is complete, you can visit
https://**username**.github.io/**repository_name**/
to preview the baseprint as a web page and PDF.
[Author a Baseprint via GitHub](https://try.perm.pub/tutorial/basecast_via_github/){ .md-button .md-button--primary target='_blank' }


## Run from the command line
Expand All @@ -72,9 +31,7 @@ basecast doc.md --baseprint=out

The above example will generate a baseprint in the `out`
subdirectory, which will contain a JATS XML file named `article.xml`.
For more details:

[See Usage](usage.md){ .md-button }
For more details, consult the [Usage page](usage.md).

To use Basecast from the command line, it needs to be either "installed" via containers
or installed locally.
Expand All @@ -86,7 +43,7 @@ Running `basecast` in an [OCI](https://opencontainers.org/){ target='_blank' }
(Docker) container is the recommended way to try `basecast`
as it avoids many common installation problems.

[Setup via containers](containers.md){ .md-button }
[Setup via containers](https://try.perm.pub/howto/basecast_container/){ .md-button }


### Setup 2: Packages
Expand All @@ -96,4 +53,4 @@ will download and cache almost a gigabyte of container image data.
Installing `basecast` directly will consume much less disk space.
However, installing packages locally is more difficult and might not work.

[Install packages](install.md){ .md-button }
[Install packages](https://try.perm.pub/howto/install_basecast/){ .md-button }
54 changes: 4 additions & 50 deletions docs/basecast/install.md
Original file line number Diff line number Diff line change
@@ -1,50 +1,4 @@
# Package Install

Basecast is developed and tested to run locally on Linux, specifically Fedora.
For Mac and Windows you should [run `basecast` via containers](containers.md).
Installing `basecast` locally on distributions other than Fedora may require additional effort.
Looking at the [files used to create the Basecast container
images](https://gitlab.com/castedo/basecast/-/tree/main/oci_images) may be helpful.


## Basic Installation

The following common tools must be installed: `git`, `pip` and `npm`.

[Installing pandoc](https://pandoc.org/installing.html#linux) is required,
with a minimum version of 3.1.6.2.

Basecast is a Python package and can be installed as a user-specific package using the following command:

```
python3 -m pip install --user basecast@git+https://gitlab.com/castedo/basecast.git
```

You also need to install the following NPM package:

```
npm install pandoc-katex-filter
```


## PDF Support

The basic installation only provides HTML previews,
which give you an idea of how the generated PDF will appear.
To enable PDF support, you need to install two additional packages:

1. [WeasyPrint Installation](https://doc.courtbouillon.org/weasyprint/stable/first_steps.html).
2. The `pdf` extra from the `basecast` package:

```
python3 -m pip install --user basecast[pdf]@git+https://gitlab.com/castedo/basecast.git
```


## System Installation

If you prefer system-wide installations instead of user-specific ones, make the following
replacements to the above instructions:

* Replace `python3 -m pip install --user ...` with `sudo python3 -m pip install ...`.
* Replace `npm install ...` with `sudo npm install -g pandoc-katex-filter ...`.
---
template: redirect.html
location: "https://try.perm.pub/howto/install_basecast/"
---
5 changes: 5 additions & 0 deletions docs/basecast/usage.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Usage

To use the command line interface,
[run basecast via OCI/Docker container](https://try.perm.pub/howto/basecast_container/)
(recommended) or
[install software packages](https://try.perm.pub/howto/install_basecast/).

```
usage: basecast [-h] [-b BASEPRINT] [-o OUTDIR] [-C DIRECTORY] [--skip-pdf]
[-m MONITOR] [-d DEFAULTS]
Expand Down
8 changes: 6 additions & 2 deletions mkdocs.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
site_name: Baseprints
site_url: https://baseprints.singlesource.pub/
theme:
name: material
custom_dir: theme
features:
- content.code.copy
- toc.integrate
- navigation.footer
- navigation.indexes
- navigation.tabs
Expand All @@ -18,5 +21,6 @@ nav:
- Basecast:
- basecast/index.md
- Usage: basecast/usage.md
- Containers: basecast/containers.md
- Package Install: basecast/install.md
watch:
- docs
- theme
20 changes: 20 additions & 0 deletions theme/redirect.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{% extends "main.html" %}

{% block extrahead %}
{{ super() -}}
<meta http-equiv="refresh" content="3; URL={{page.meta.location}}">
{% endblock extrahead %}

{% block content %}
<center>
<p>
This page is now located at:
</p>

<a href="{{page.meta.location}}">{{page.meta.location}}</a>

<p>
You should be be automatically redirected in 3 seconds.
</p>
</center>
{% endblock content %}

0 comments on commit 564a891

Please sign in to comment.