releaser

package module
v1.0.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 15, 2024 License: BSD-2-Clause Imports: 3 Imported by: 5

README

releaser

Go Reference

A Go library for handling the formatting of Defacto2 releasers.

Releasers are the groups or organisations that create the art, music, demos, intros, cracks, etc. that are found on the Defacto2 website. They are also the sites and boards that have hosted the files and communities.

The library is used by the Defacto2 website to format the named groups and organizations.

There are four main functions:

  • Clean - Cleans the named releaser to correct any issues with syntax or casing.
  • Humanize - Formats the URL path of a releaser into a human readable string.
  • Link - Formats the URL path of a releaser for use as a HTML link description.
  • Obfuscate - Formats the named releaser into a partial URL path.

The name.Special func contains the list of releaser names with special syntax.

The initialism.Initialism func handles the releaser alternative spellings, acronyms and initialisms.

Usage

In your Go project, import the releaser library.

go get github.com/Defacto2/releaser

Use the functions.

import "github.com/Defacto2/releaser"

func main() {
    // Clean the the string releaser name.
    name := releaser.Clean("  the  knightmare  bbs ")
    fmt.Println(name) // Output: Knightmare BBS

    // Format the releaser name into a URL path.
    urlPath = releaser.Obfuscate("the knightmare bbs")
    fmt.Println(urlPath) // Output: knightmare-bbs

    // Format the releaser name into a human readable string.
    const url = "https://defacto2.net/organizations/knightmare-bbs"
    name = releaser.Humanize(path.Base(url))
    fmt.Println(name) // Output: Knightmare BBS

    // Format the releaser names into a HTML link description.
    const url = "https://defacto2.net/organizations/class*paradigm*razor-1911"
    name = releaser.Link(path.Base(url))
    fmt.Println(name) // Output: Class + Paradigm + Razor 1911
}

Documentation

Overview

Package releaser provides functions for cleaning and formatting the scene names and titles.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Cell added in v1.0.3

func Cell(s string) string

Cell formats the string to be used as a cell in a database table. This includes the removal of duplicate spaces and the stripping of incompatible characters. The removal of excess whitespace and if found "The " prefix from BBS and FTP named sites.

Example:

Cell("  Defacto2  demo  group.") = "DEFACTO2 DEMO GROUP"
Cell("the x bbs") = "X BBS"
Cell("defacto2.net") = "DEFACTO2NET"

func Clean

func Clean(s string) string

Clean fixes the malformed string. This includes the removal of duplicate spaces and the stripping of incompatible characters. The removal of excess whitespace and if found "The " prefix from BBS and FTP named sites.

Example:

Clean("  Defacto2  demo  group.") = "Defacto2 Demo Group"
Clean("the x bbs") = "X BBS"
Clean("The X Ftp") = "X FTP"

func Humanize

func Humanize(path string) string

Humanize deobfuscates the URL path and returns the formatted, human-readable group name. The path is expected to be in the format of a URL path without the scheme or domain. If the URL path contains invalid characters then an empty string is returned.

Example:

Humanize("defacto2") = "Defacto2"
Humanize("razor-1911-demo") = "Razor 1911 Demo"
Humanize("razor-1911-demo-ampersand-skillion") = "Razor 1911 Demo & Skillion"
Humanize("north-american-pirate_phreak-association") = "North American Pirate-Phreak Association"
Humanize("razor-1911-demo*trsi") = "Razor 1911 Demo, TRSi"
Humanize("razor-1911-demo#trsi") = "" // invalid # character
func Link(path string) string

Humanize deobfuscates the URL path and applies releaser.Humanize. In addition, the humanized name is formatted to be used as a link description. If the URL path contains invalid characters then an empty string is returned.

func Obfuscate added in v1.0.0

func Obfuscate(s string) string

Obfuscate formats the string to be used as a URL path.

Example:

Obfuscate("ACiD Productions") = "acid-productions"
Obfuscate("Razor 1911 Demo & Skillion") = "razor-1911-demo-ampersand-skillion"
Obfuscate("TDU-Jam!") = "tdu_jam"

Types

This section is empty.

Directories

Path Synopsis
Package fix provides functions for cleaning and formatting strings of known words and group names.
Package fix provides functions for cleaning and formatting strings of known words and group names.
Package initialism provides a list of alternative spellings, acronyms and initialisms for the named releasers.
Package initialism provides a list of alternative spellings, acronyms and initialisms for the named releasers.
Package name provides functionality for handling the URL path of a releaser.
Package name provides functionality for handling the URL path of a releaser.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL