Skip to content

Commit

Permalink
Merge pull request #2 from peaky76/quicklink
Browse files Browse the repository at this point in the history
Quicklink
  • Loading branch information
peaky76 committed Oct 27, 2023
2 parents 3d3d5a8 + 705595b commit 594fb6e
Show file tree
Hide file tree
Showing 5 changed files with 98 additions and 2 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,14 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.3.0] (2023-10-27)

#### New Features

- `wikicite link`
- `wikicite quicklink`
- `wikicite ql` (quicklink alias)

## [0.2.0] (2023-10-16)

#### New Features
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "wikicite"
version = "0.2.0"
version = "0.3.0"
description = "Create ready-to-use Wikipedia citations from a series of inputs"
authors = ["peaky76 <robertjamespeacock@gmail.com>"]
readme = "README.md"
Expand Down
10 changes: 9 additions & 1 deletion tests/test_wikicite.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@
from wikicite.wikicite import cite, TODAY


def test_wikicite_link():
runner = CliRunner()
result = runner.invoke(cite, ["link", "Test"])
assert result.exit_code == 0
assert "[[Test]]" in result.output


def test_basic_full_citation():
runner = CliRunner()
result = runner.invoke(
Expand Down Expand Up @@ -32,4 +39,5 @@ def test_basic_full_citation():

def runner():
test_basic_full_citation()
print("1 test passed successfully")
test_wikicite_link()
print("2 tests passed successfully")
51 changes: 51 additions & 0 deletions wikicite/links.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
[asc]
page = "Ascot Racecourse"
alias = "Ascot"

[ayr]
page = "Ayr Racecourse"
alias = "Ayr"

[don]
page = "Doncaster Racecourse"
alias = "Doncaster"

[eps]
page = "Epsom Downs Racecourse"
alias = "Epsom"

[ham]
page = "Hamilton Park Racecourse"
alias = "Hamilton"

[lin]
page = "Lingfield Park Racecourse"
alias = "Lingfield"

[not]
page = "Nottingham Racecourse"
alias = "Nottingham"

[red]
page = "Redcar Racecourse"
alias = "Redcar"

[sou]
page = "Southwell Racecourse"
alias = "Southwell"

[thi]
page = "Thirsk Racecourse"
alias = "Thirsk"

[wol]
page = "Wolverhampton Racecourse"
alias = "Wolverhampton"

[mo]
page = "Sheikh Mohammed bin Rashid Al Maktoum"
alias = "Sheikh Mohammed"

[qe2]
page = "Queen Elizabeth II"
alias = "The Queen"
29 changes: 29 additions & 0 deletions wikicite/wikicite.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import os
import click
import tomllib

from wikicite.create_citation import create_citation
from wikicite.get_reference_name import get_reference_name
import wikicite.markdown as md
Expand All @@ -14,12 +15,40 @@
with open(os.path.join(__location__, "./sources.toml"), "rb") as file:
sources = tomllib.load(file)

with open(os.path.join(__location__, "./links.toml"), "rb") as file:
links = tomllib.load(file)


@click.group()
def cite():
pass


@cite.command()
@click.argument("page", type=str)
@click.option("-a", "--alias", type=str, default="", help="alias for page")
def link(page, alias):
click.echo(md.link(page, alias or None))


@cite.command()
@click.argument(
"abbr",
type=click.Choice(links.keys()),
)
def ql(abbr):
click.echo(md.link(links[abbr]["page"], links[abbr]["alias"]))


@cite.command()
@click.argument(
"abbr",
type=click.Choice(links.keys()),
)
def quicklink(abbr):
click.echo(md.link(links[abbr]["page"], links[abbr]["alias"]))


@cite.command()
@common_options
@click.option("-p", "--publisher", type=str, prompt=True, help="publisher")
Expand Down

0 comments on commit 594fb6e

Please sign in to comment.