Skip to content

Commit

Permalink
Merge branch 'main' into bump-textual
Browse files Browse the repository at this point in the history
  • Loading branch information
davep authored May 24, 2023
2 parents db70855 + af7f1c4 commit 301fe5a
Show file tree
Hide file tree
Showing 6 changed files with 68 additions and 3 deletions.
6 changes: 6 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

## [0.6.0] - 2023-05-24

### Added

- Added Codeberg as a recognised forge for the "forge quick view".

### Changed

- Relaxed the required [Textual](https://github.com/Textualize/textual)
dependency version requirement.

Expand Down
1 change: 1 addition & 0 deletions frogmouth/dialogs/help_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
| `about` | `a` | | Show details about the application |
| `bookmarks` | `b`, `bm` | | Show the bookmarks list |
| `bitbucket` | `bb` | `<repo-info>` | View a file on BitBucket (see below) |
| `codeberg` | `cb` | `<repo-info>` | View a file on Codceberg (see below) |
| `changelog` | `cl` | | View the Frogmouth ChangeLog |
| `chdir` | `cd` | `<dir>` | Switch the local file browser to a new directory |
| `contents` | `c`, `toc` | | Show the table of contents for the document |
Expand Down
9 changes: 9 additions & 0 deletions frogmouth/screens/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
from ..dialogs import ErrorDialog, HelpDialog, InformationDialog, InputDialog
from ..utility import (
build_raw_bitbucket_url,
build_raw_codeberg_url,
build_raw_github_url,
build_raw_gitlab_url,
is_likely_url,
Expand Down Expand Up @@ -275,6 +276,14 @@ async def on_omnibox_bit_bucket_command(
"""
await self._from_forge("BitBucket", event, build_raw_bitbucket_url)

async def on_omnibox_codeberg_command(self, event: Omnibox.CodebergCommand) -> None:
"""Handle a Codeberg shortcut command.
Args:
event: The Codeberg shortcut command event to handle.
"""
await self._from_forge("Codeberg", event, build_raw_codeberg_url)

def on_omnibox_about_command(self) -> None:
"""Handle being asked to show the about dialog."""
self.action_about()
Expand Down
12 changes: 9 additions & 3 deletions frogmouth/utility/__init__.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
"""General utility and support code."""

from .forge import build_raw_bitbucket_url, build_raw_github_url, build_raw_gitlab_url
from .forge import (
build_raw_bitbucket_url,
build_raw_codeberg_url,
build_raw_github_url,
build_raw_gitlab_url,
)
from .type_tests import is_likely_url, maybe_markdown

__all__ = [
"build_raw_bitbucket_url",
"build_raw_codeberg_url",
"build_raw_github_url",
"build_raw_gitlab_url",
"build_raw_bitbucket_url",
"maybe_markdown",
"is_likely_url",
"maybe_markdown",
]
31 changes: 31 additions & 0 deletions frogmouth/utility/forge.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,3 +143,34 @@ async def build_raw_bitbucket_url(
branch,
desired_file,
)


async def build_raw_codeberg_url(
owner: str,
repository: str,
branch: str | None = None,
desired_file: str | None = None,
) -> URL | None:
"""Attempt to get the Codeberg raw URL for the given file.
Args:
owner: The owner of the repository to look in.
repository: The repository to look in.
branch: The optional branch to look in.
desired_file: Optional name of the file to go looking for.
Returns:
The URL for the file, or `None` if none could be guessed.
If the branch isn't supplied then `main` and `master` will be tested.
If the target file isn't supplied it's assumed that `README.md` is the
target.
"""
return await build_raw_forge_url(
"https://codeberg.org/{owner}/{repository}/raw//branch/{branch}/{file}",
owner,
repository,
branch,
desired_file,
)
12 changes: 12 additions & 0 deletions frogmouth/widgets/omnibox.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ def watch_visiting(self) -> None:
"bm": "bookmarks",
"bb": "bitbucket",
"c": "contents",
"cb": "codeberg",
"cd": "chdir",
"cl": "changelog",
"gh": "github",
Expand Down Expand Up @@ -332,6 +333,17 @@ def command_bitbucket(self, tail: str) -> None:
"""
self._forge_quick_look(self.BitBucketCommand, tail)

class CodebergCommand(ForgeCommand):
"""The Codeberg quick load command."""

def command_codeberg(self, tail: str) -> None:
"""The Codeberg command.
Args:
tail: The tail of the command.
"""
self._forge_quick_look(self.CodebergCommand, tail)

def command_discord(self, _: str) -> None:
"""The command to visit the Textualize discord server."""
open_url(DISCORD)
Expand Down

0 comments on commit 301fe5a

Please sign in to comment.