Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: readium/go-toolkit
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v0.7.1
Choose a base ref
...
head repository: readium/go-toolkit
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: develop
Choose a head ref
  • 16 commits
  • 14 files changed
  • 2 contributors

Commits on Feb 7, 2025

  1. Update changelog for 0.7.1 release

    chocolatkey committed Feb 7, 2025
    Copy the full SHA
    a89c47e View commit details

Commits on Feb 20, 2025

  1. Add version info to marshalled WebPub metadata

    chocolatkey committed Feb 20, 2025
    Copy the full SHA
    e10c19d View commit details
  2. Update and tweak goreleaser to add proper buildinfo

    chocolatkey committed Feb 20, 2025
    Copy the full SHA
    32b2154 View commit details

Commits on Feb 21, 2025

  1. Fix Docker build

    chocolatkey committed Feb 21, 2025
    Copy the full SHA
    44a37e6 View commit details
  2. cloud build test 1

    chocolatkey committed Feb 21, 2025
    Copy the full SHA
    b15865c View commit details
  3. cloud build test 2

    chocolatkey committed Feb 21, 2025
    Copy the full SHA
    0929180 View commit details
  4. Move version to package, add version to rwp command

    chocolatkey committed Feb 21, 2025
    Copy the full SHA
    f035f88 View commit details
  5. cloud build test 3

    chocolatkey committed Feb 21, 2025
    Copy the full SHA
    6c53fb9 View commit details
  6. Add additional fallback for version

    chocolatkey committed Feb 21, 2025
    Copy the full SHA
    48883e3 View commit details
  7. prevent injection of version during metadata testing

    chocolatkey committed Feb 21, 2025
    Copy the full SHA
    d24a115 View commit details
  8. Copy the full SHA
    9748370 View commit details
  9. only use VCS info if build is of the go-toolkit

    chocolatkey committed Feb 21, 2025
    Copy the full SHA
    1a8d2ff View commit details
  10. Bump goreleaser/goreleaser-action from 5.1.0 to 6.2.1 (#196)

    Signed-off-by: dependabot[bot] <[email protected]>
    Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
    dependabot[bot] authored Feb 21, 2025

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    e903edc View commit details
  11. Add EPUB a11y 1.1 Conformance Support (#195)

    chocolatkey authored Feb 21, 2025

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    500aa9f View commit details

Commits on Feb 24, 2025

  1. Update changelog

    chocolatkey committed Feb 24, 2025
    Copy the full SHA
    6b2f2dd View commit details

Commits on Feb 25, 2025

  1. Fix builds for arm

    chocolatkey committed Feb 25, 2025
    Copy the full SHA
    43c0638 View commit details
5 changes: 3 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -32,7 +32,7 @@ jobs:
go-version: '>=1.23.0'
cache: false
- name: Build release
uses: goreleaser/goreleaser-action@5742e2a039330cbb23ebf35f046f814d4c6ff811 # v5.1.0
uses: goreleaser/goreleaser-action@90a3faa9d0182683851fbfa97ca1a2cb983bfca3 # v6.2.1
with:
distribution: goreleaser
version: latest
@@ -55,7 +55,7 @@ jobs:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@6524bf65af31da8d45b59e8c27de4bd072b392f5 # v3.8.0
- name: Build and push Docker image
run: docker buildx build --platform=linux/amd64,linux/arm64,linux/arm/v7 . --file Dockerfile --tag $IMAGE_NAME --label "runnumber=${GITHUB_RUN_ID}"
run: docker buildx build --platform=linux/amd64,linux/arm64,linux/arm/v7 . --file Dockerfile --tag $IMAGE_NAME --label "runnumber=${GITHUB_RUN_ID}" --build-arg NO_SNAPSHOT=true
- name: Log in to registry
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
- name: Push image
@@ -73,4 +73,5 @@ jobs:
echo VERSION=$VERSION
docker buildx build --push \
--tag $IMAGE_ID:$VERSION \
--build-arg NO_SNAPSHOT=true \
--platform linux/amd64,linux/arm64,linux/arm/v7 .
28 changes: 15 additions & 13 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
# Make sure to check the documentation at https://goreleaser.com
version: 2
before:
hooks:
- go mod tidy
- go generate ./...
gomod:
proxy: true
builds:
- main: ./cmd/rwp/
env:
@@ -13,21 +16,20 @@ builds:
- linux
- windows
- darwin
goarch:
- '386'
- amd64
- arm
- arm64
goarm:
- '7'
goamd64:
- v3

# - main: ./cmd/server/
# env:
# - CGO_ENABLED=0
# id: rwp-server
# binary: rwp-server
# goos:
# - linux
# - windows
# - darwin
ldflags:
- -s -w

archives:
- format: tar.gz
- formats: tar.gz
# this name template makes the OS and Arch compatible with the results of uname.
# Used to start with {{ .ProjectName }}
name_template: >-
@@ -40,8 +42,8 @@ archives:
# use zip for windows archives
format_overrides:
- goos: windows
format: zip
formats: ['zip']
checksum:
name_template: 'checksums.txt'
snapshot:
name_template: "{{ incpatch .Version }}-next"
version_template: "{{ incpatch .Version }}-next"
28 changes: 27 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -6,7 +6,33 @@ All notable changes to this project will be documented in this file.

## [Unreleased]

None
## [0.8.1] - 2025-02-24

### Changed

- Docker containers & releases now properly build ARM (32-bit) images with v7 (not v6) support

## [0.8.0] - 2025-02-24

### Added

- Support for [EPUB Accessibility 1.1](https://www.w3.org/TR/epub-a11y-11/) conformance values
- `--version` flag for `rwp`
- Output of `go-toolkit` version in WebPub metadata. [Based on the Go module pseudo-version](https://github.com/readium/go-toolkit/issues/80#issuecomment-2673888192)

### Changed

- A11y `conformsTo` values are now sorted from highest to lowest conformance level

## [0.7.1] - 2025-02-07

### Added

- Add [TDMRep](https://www.w3.org/community/reports/tdmrep/CG-FINAL-tdmrep-20240510/#sec-epub3) support for EPUB 2 & 3.

### Fixed

- Fix typo in EAA exemption.

## [0.7.0] - 2025-01-31

10 changes: 7 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
FROM --platform=$BUILDPLATFORM golang:1-bookworm@sha256:3149bc5043fa58cf127fd8db1fdd4e533b6aed5a40d663d4f4ae43d20386665f AS builder
ARG BUILDARCH TARGETOS TARGETARCH
ARG NO_SNAPSHOT=false

# Install GoReleaser
RUN wget --no-verbose "https://github.com/goreleaser/goreleaser/releases/download/v1.26.2/goreleaser_1.26.2_$BUILDARCH.deb"
RUN dpkg -i "goreleaser_1.26.2_$BUILDARCH.deb"
RUN wget --no-verbose "https://github.com/goreleaser/goreleaser/releases/download/v2.7.0/goreleaser_2.7.0_$BUILDARCH.deb"
RUN dpkg -i "goreleaser_2.7.0_$BUILDARCH.deb"

# Create and change to the app directory.
WORKDIR /app
@@ -17,12 +18,15 @@ RUN go mod download
# Copy local code to the container image.
COPY . ./

RUN git describe --tags --always

# RUN git lfs pull && ls -alh publications

# Run goreleaser
RUN --mount=type=cache,target=/root/.cache/go-build \
--mount=type=cache,target=/go/pkg \
GOOS=$TARGETOS GOARCH=$TARGETARCH goreleaser build --single-target --id rwp --skip=validate --snapshot --output ./rwp
GOOS=$TARGETOS GOARCH=$TARGETARCH GOAMD64=v3 GOARM=7 \
goreleaser build --single-target --id rwp --skip=validate $(case "$NO_SNAPSHOT" in yes|true|1) ;; *) echo "--snapshot";; esac) --output ./rwp

# Run tests
# FROM builder AS tester
6 changes: 4 additions & 2 deletions cmd/rwp/cmd/root.go
Original file line number Diff line number Diff line change
@@ -3,13 +3,15 @@ package cmd
import (
"os"

"github.com/readium/go-toolkit/pkg/util/version"
"github.com/spf13/cobra"
)

// rootCmd represents the base command when called without any subcommands
var rootCmd = &cobra.Command{
Use: "rwp",
Short: "Utilities for Readium Web Publications",
Use: "rwp",
Short: "Utilities for Readium Web Publications",
Version: version.Version,
}

// Execute adds all child commands to the root command and sets flags appropriately.
63 changes: 61 additions & 2 deletions pkg/manifest/a11y.go
Original file line number Diff line number Diff line change
@@ -2,6 +2,7 @@ package manifest

import (
"encoding/json"
"slices"

"github.com/pkg/errors"
"github.com/readium/go-toolkit/pkg/internal/extensions"
@@ -12,7 +13,7 @@ import (
// https://www.w3.org/2021/a11y-discov-vocab/latest/
// https://readium.org/webpub-manifest/schema/a11y.schema.json
type A11y struct {
ConformsTo []A11yProfile `json:"conformsTo,omitempty"` // An established standard to which the described resource conforms.
ConformsTo A11yProfileList `json:"conformsTo,omitempty"` // An established standard to which the described resource conforms.
Certification *A11yCertification `json:"certification,omitempty"` // Certification of accessible publications.
Summary string `json:"summary,omitempty"` // A human-readable summary of specific accessibility features or deficiencies, consistent with the other accessibility metadata but expressing subtleties such as "short descriptions are present but long descriptions will be needed for non-visual users" or "short descriptions are present and no long descriptions are needed."
AccessModes []A11yAccessMode `json:"accessMode,omitempty"` // The human sensory perceptual system or cognitive faculty through which a person may process or perceive information.
@@ -25,7 +26,7 @@ type A11y struct {
// NewA11y creates a new empty A11y.
func NewA11y() A11y {
return A11y{
ConformsTo: []A11yProfile{},
ConformsTo: A11yProfileList{},
AccessModes: []A11yAccessMode{},
AccessModesSufficient: [][]A11yPrimaryAccessMode{},
Features: []A11yFeature{},
@@ -47,6 +48,7 @@ func (a *A11y) Merge(other *A11y) {
}

a.ConformsTo = extensions.AppendIfMissing(a.ConformsTo, other.ConformsTo...)
a.ConformsTo.Sort()

if other.Certification != nil {
a.Certification = other.Certification
@@ -86,6 +88,7 @@ func A11yFromJSON(rawJSON map[string]interface{}) (*A11y, error) {
return nil, errors.Wrap(err, "failed unmarshalling 'conformsTo'")
}
a.ConformsTo = A11yProfilesFromStrings(conformsTo)
a.ConformsTo.Sort()

if certJSON, ok := rawJSON["certification"].(map[string]interface{}); ok {
c := A11yCertification{
@@ -171,14 +174,70 @@ const (
EPUBA11y10WCAG20AA A11yProfile = "http://www.idpf.org/epub/a11y/accessibility-20170105.html#wcag-aa"
// EPUB Accessibility 1.0 - WCAG 2.0 Level AAA
EPUBA11y10WCAG20AAA A11yProfile = "http://www.idpf.org/epub/a11y/accessibility-20170105.html#wcag-aaa"
// EPUB Accessibility 1.1 - WCAG 2.0 Level A
EPUBA11y11WCAG20A A11yProfile = "https://www.w3.org/TR/epub-a11y-11#wcag-2.0-a"
// EPUB Accessibility 1.1 - WCAG 2.0 Level AA
EPUBA11y11WCAG20AA A11yProfile = "https://www.w3.org/TR/epub-a11y-11#wcag-2.0-aa"
// EPUB Accessibility 1.1 - WCAG 2.0 Level AAA
EPUBA11y11WCAG20AAA A11yProfile = "https://www.w3.org/TR/epub-a11y-11#wcag-2.0-aaa"
// EPUB Accessibility 1.1 - WCAG 2.1 Level A
EPUBA11y11WCAG21A A11yProfile = "https://www.w3.org/TR/epub-a11y-11#wcag-2.1-a"
// EPUB Accessibility 1.1 - WCAG 2.1 Level AA
EPUBA11y11WCAG21AA A11yProfile = "https://www.w3.org/TR/epub-a11y-11#wcag-2.1-aa"
// EPUB Accessibility 1.1 - WCAG 2.1 Level AAA
EPUBA11y11WCAG21AAA A11yProfile = "https://www.w3.org/TR/epub-a11y-11#wcag-2.1-aaa"
// EPUB Accessibility 1.1 - WCAG 2.2 Level A
EPUBA11y11WCAG22A A11yProfile = "https://www.w3.org/TR/epub-a11y-11#wcag-2.2-a"
// EPUB Accessibility 1.1 - WCAG 2.2 Level AA
EPUBA11y11WCAG22AA A11yProfile = "https://www.w3.org/TR/epub-a11y-11#wcag-2.2-aa"
// EPUB Accessibility 1.1 - WCAG 2.2 Level AAA
EPUBA11y11WCAG22AAA A11yProfile = "https://www.w3.org/TR/epub-a11y-11#wcag-2.2-aaa"
)

// Used for sorting. Make sure to keep it up-to-date with the consts
var a11yProfileRanking = map[A11yProfile]int{
EPUBA11y10WCAG20A: 1,
EPUBA11y10WCAG20AA: 2,
EPUBA11y10WCAG20AAA: 3,
EPUBA11y11WCAG20A: 4,
EPUBA11y11WCAG20AA: 5,
EPUBA11y11WCAG20AAA: 6,
EPUBA11y11WCAG21A: 7,
EPUBA11y11WCAG21AA: 8,
EPUBA11y11WCAG21AAA: 9,
EPUBA11y11WCAG22A: 10,
EPUBA11y11WCAG22AA: 11,
EPUBA11y11WCAG22AAA: 12,
}

func A11yProfilesFromStrings(strings []string) []A11yProfile {
return fromStrings(strings, func(str string) A11yProfile {
return A11yProfile(str)
})
}

func (p A11yProfile) Compare(other A11yProfile) int {
// Compare based on the compatibility level
if p == other {
return 0
}

pRank := a11yProfileRanking[p]
oRank := a11yProfileRanking[other]
return oRank - pRank
}

type A11yProfileList []A11yProfile

func (l A11yProfileList) Sort() {
if len(l) <= 1 {
return
}
slices.SortFunc(l, func(a, b A11yProfile) int {
return a.Compare(b)
})
}

// A11yCertification represents a certification for an accessible publication.
type A11yCertification struct {
CertifiedBy string `json:"certifiedBy,omitempty"` // Identifies a party responsible for the testing and certification of the accessibility of a Publication.
18 changes: 18 additions & 0 deletions pkg/manifest/a11y_test.go
Original file line number Diff line number Diff line change
@@ -87,6 +87,24 @@ func TestA11yUnmarshalConformsToArray(t *testing.T) {
assert.Equal(t, e, m, "unmarshalled JSON object should be equal to A11y object")
}

func TestA11ySortConformsTo(t *testing.T) {
a := A11yProfileList{
EPUBA11y10WCAG20A,
EPUBA11y11WCAG22A,
EPUBA11y11WCAG20AA,
EPUBA11y11WCAG21AA,
EPUBA11y11WCAG22AAA,
}
a.Sort()
assert.Equal(t, A11yProfileList{
EPUBA11y11WCAG22AAA,
EPUBA11y11WCAG22A,
EPUBA11y11WCAG21AA,
EPUBA11y11WCAG20AA,
EPUBA11y10WCAG20A,
}, a)
}

func TestA11yUnmarshalAccessModeSufficientContainingBothStringsAndArrays(t *testing.T) {
var m A11y
assert.NoError(t, json.Unmarshal([]byte(`{"accessModeSufficient": ["auditory", ["visual", "tactile"], [], "visual"]}`), &m))
8 changes: 8 additions & 0 deletions pkg/manifest/metadata.go
Original file line number Diff line number Diff line change
@@ -8,6 +8,7 @@ import (
"github.com/go-viper/mapstructure/v2"
"github.com/pkg/errors"
"github.com/readium/go-toolkit/pkg/internal/util"
"github.com/readium/go-toolkit/pkg/util/version"
)

// TODO replace with generic
@@ -452,6 +453,9 @@ func (m *Metadata) UnmarshalJSON(b []byte) error {
return nil
}

// If you really don't want the version info in your manifest, you can blank this value.
var ToolkitVersionKey = "https://github.com/readium/go-toolkit/releases"

func (m Metadata) MarshalJSON() ([]byte, error) {
j := make(map[string]interface{})
if m.OtherMetadata != nil {
@@ -460,6 +464,10 @@ func (m Metadata) MarshalJSON() ([]byte, error) {
}
}

if ToolkitVersionKey != "" {
j[ToolkitVersionKey] = version.Version
}

if m.Presentation != nil {
j["presentation"] = m.Presentation
}
4 changes: 4 additions & 0 deletions pkg/manifest/metadata_test.go
Original file line number Diff line number Diff line change
@@ -8,6 +8,10 @@ import (
"github.com/stretchr/testify/assert"
)

func init() {
ToolkitVersionKey = "" // Prevent injection of version during testing
}

func TestMetadataUnmarshalMinimalJSON(t *testing.T) {
var m Metadata
assert.NoError(t, json.Unmarshal([]byte(`{"title": "Title"}`), &m))
25 changes: 17 additions & 8 deletions pkg/parser/epub/metadata.go
Original file line number Diff line number Diff line change
@@ -675,7 +675,7 @@ func (m PubMetadataAdapter) TDM() *manifest.TDM {
}

func (m PubMetadataAdapter) a11yConformsTo() []manifest.A11yProfile {
profiles := []manifest.A11yProfile{}
profiles := manifest.A11yProfileList{}

if items, ok := m.items[VocabularyDCTerms+"conformsto"]; ok {
for _, item := range items {
@@ -691,32 +691,41 @@ func (m PubMetadataAdapter) a11yConformsTo() []manifest.A11yProfile {
}
}

profiles.Sort()
return profiles
}

func a11yProfile(value string) manifest.A11yProfile {
switch value {
case "EPUB Accessibility 1.1 - WCAG 2.0 Level A",
"http://idpf.org/epub/a11y/accessibility-20170105.html#wcag-a",
case "http://idpf.org/epub/a11y/accessibility-20170105.html#wcag-a",
"http://www.idpf.org/epub/a11y/accessibility-20170105.html#wcag-a",
"https://idpf.org/epub/a11y/accessibility-20170105.html#wcag-a",
"https://www.idpf.org/epub/a11y/accessibility-20170105.html#wcag-a":
return manifest.EPUBA11y10WCAG20A

case "EPUB Accessibility 1.1 - WCAG 2.0 Level AA",
"http://idpf.org/epub/a11y/accessibility-20170105.html#wcag-aa",
case "http://idpf.org/epub/a11y/accessibility-20170105.html#wcag-aa",
"http://www.idpf.org/epub/a11y/accessibility-20170105.html#wcag-aa",
"https://idpf.org/epub/a11y/accessibility-20170105.html#wcag-aa",
"https://www.idpf.org/epub/a11y/accessibility-20170105.html#wcag-aa":
return manifest.EPUBA11y10WCAG20AA

case "EPUB Accessibility 1.1 - WCAG 2.0 Level AAA",
"http://idpf.org/epub/a11y/accessibility-20170105.html#wcag-aaa",
case "http://idpf.org/epub/a11y/accessibility-20170105.html#wcag-aaa",
"http://www.idpf.org/epub/a11y/accessibility-20170105.html#wcag-aaa",
"https://idpf.org/epub/a11y/accessibility-20170105.html#wcag-aaa",
"https://www.idpf.org/epub/a11y/accessibility-20170105.html#wcag-aaa":
return manifest.EPUBA11y10WCAG20AAA

case "EPUB Accessibility 1.1 - WCAG 2.0 Level A":
return manifest.EPUBA11y11WCAG20A
case "EPUB Accessibility 1.1 - WCAG 2.0 Level AA":
return manifest.EPUBA11y11WCAG20AA
case "EPUB Accessibility 1.1 - WCAG 2.0 Level AAA":
return manifest.EPUBA11y11WCAG20AAA
case "EPUB Accessibility 1.1 - WCAG 2.1 Level A":
return manifest.EPUBA11y11WCAG21A
case "EPUB Accessibility 1.1 - WCAG 2.1 Level AA":
return manifest.EPUBA11y11WCAG21AA
case "EPUB Accessibility 1.1 - WCAG 2.1 Level AAA":
return manifest.EPUBA11y11WCAG21AAA
default:
return ""
}
Loading