releaser

package module
v1.1.3 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2024 License: BSD-2-Clause Imports: 4 Imported by: 5

README

Defacto2 / releaser

Go Reference Go Report Card

A Go library for handling the formatting of Defacto2 releasers. See the reference documentation for additional usage and examples.

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.

Usage

In your Go project, import the releaser library.

package main

import (
	"fmt"
	"path"

	"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 for use in a database cell.
	data := releaser.Cell("  the  knightmare  bbs ")
	fmt.Println(data) // 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 url1 = "https://defacto2.net/g/knightmare-bbs"
	name = releaser.Humanize(path.Base(url1))
	fmt.Println(name) // Output: Knightmare BBS

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

Documentation

Overview

Package releaser provides string functions for cleaning and reformatting the names of release groups and partial URL paths.

Index

Examples

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.

  • The removal of duplicate spaces
  • The removal of excess whitespace
  • If found "The " prefix from BBS and FTP named sites
  • The stripping of incompatible characters

Compatible characters include: A-Z a-z À-Ö Ø-ö ø-ÿ 0-9 - , &

Example:

Cell("  Defacto2  demo  group.") = "DEFACTO2 DEMO GROUP"
Cell("the x bbs") = "X BBS"
Cell("defacto2.net") = "DEFACTO2NET"
Cell("TDT / TRSi") = "TDT TRSI"
Cell("TDT,TRSi") = "TDT, TRSI"
Example
package main

import (
	"fmt"

	"github.com/Defacto2/releaser"
)

func main() {
	s := "  Defacto2  demo  group."
	fmt.Println(releaser.Cell(s))
}
Output:

DEFACTO2 DEMO GROUP

func Clean

func Clean(s string) string

Clean fixes the malformed string and applies title case formatting. It does not apply any name deobfuscations such as initials or abbreviations, as it only stylizes the string.

  • The removal of duplicate spaces
  • The removal of excess whitespace
  • If found "The " prefix from BBS and FTP named sites
  • The stripping of incompatible characters

Compatible characters include: A-Z a-z À-Ö Ø-ö ø-ÿ 0-9 - , &

Example:

Clean("  Defacto2  demo  group.") = "Defacto2 Demo Group"
Clean("the x bbs") = "X BBS"
Clean("The X Ftp") = "X FTP"
Clean("tdt / trsi") = "Tdt Trsi" // behaves as a single group
Clean("tdt,trsi") = "Tdt, TRSi"  // behaves as two groups
Example
package main

import (
	"fmt"

	"github.com/Defacto2/releaser"
)

func main() {
	s := "  Defacto2  demo  group."
	fmt.Println(releaser.Clean(s))
}
Output:

Defacto2 Demo Group

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("coop") = "TDT / TRSi"
Humanize("united-software-association*fairlight") =
	"United Software Association + Fairlight PC Division" // special name
Humanize("razor-1911-demo*trsi") = "Razor 1911 Demo, TRSi"
Humanize("razor-1911-demo#trsi") = "" // invalid # character
Example
package main

import (
	"fmt"

	"github.com/Defacto2/releaser"
)

func main() {
	path := "razor-1911-demo"
	fmt.Println(releaser.Humanize(path))
}
Output:

Razor 1911 Demo

func Index added in v1.1.0

func Index(path string) string

Index deobfuscates the URL path and applies releaser.Humanize so that it can be stored in a database table as a releaser key and index in the database table.

Example
package main

import (
	"fmt"

	"github.com/Defacto2/releaser"
)

func main() {
	fmt.Println(releaser.Index("united-software-association*fairlight"))
	fmt.Println(releaser.Index("class*paradigm*razor-1911"))
	fmt.Println(releaser.Index("coop"))
}
Output:

UNITED SOFTWARE ASSOCIATION, FAIRLIGHT
CLASS, PARADIGM, RAZOR 1911
COOP
func Link(path string) string

Link 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.

Example:

Link("razor-1911-demo*trsi") = "Razor 1911 Demo + TRSi"
Link("class*paradigm*razor-1911") = "Class + Paradigm + Razor 1911"
Link("united-software-association*fairlight") = "United Software Association + Fairlight PC Division"

func Obfuscate added in v1.0.0

func Obfuscate(s string) string

Obfuscate cleans and formats the string for use as a URL path. The string is expected to be a release group name or an known initialism, acronym or special name.

Beware that initialisms and acronyms often are not unique and an unexpected URL may be returned.

Example:

Obfuscate("ACiD Productions") = "acid-productions"
Obfuscate("Razor 1911 Demo & Skillion") = "razor-1911-demo-ampersand-skillion"
Obfuscate("TDU-Jam!") = "tdu_jam"
Obfuscate("The 12AM BBS.") = "12am-bbs"

Examples using unique, known initialisms:

Obfuscate("fltdox") = "fairlight-dox"
Obfuscate("tdt") = "the-dream-team"

Examples using special names:

Obfuscate("TDT / TRSi") = "coop"
Obfuscate("United Software Association + Fairlight PC Division") = "united-software-association*fairlight"
Example
package main

import (
	"fmt"

	"github.com/Defacto2/releaser"
)

func main() {
	s := "Defacto2 Demo Group."
	fmt.Println(releaser.Obfuscate(s))
}
Output:

defacto2-demo-group

func Title added in v1.1.0

func Title(s string) string

Title formats the string to be used as a title or the basis for a LIKE SQL query. Any known initialisms, acronyms or special names are deobfuscated.

Example:

Title("razor 1911") = "Razor 1911"
Title("_.=[   RaZoR 1911   ]=._") = "Razor 1911"
Title("COOP") = "TDT / TRSi"
Title("tdt / trsi") = "TDT / TRSi"
Title("nappa") = "North American Pirate-Phreak Association"

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