feat(commands): implement :CP open [problem|contest|standings] (#319)
## Problem There was no way to open a problem, contest, or standings page in the browser from within the plugin. ## Solution Add `contest_url` and `standings_url` to `MetadataResult` and persist them in the cache. Add `cache.get_open_urls` to resolve all three URLs. Wire up `:CP open [problem|contest|standings]` in `commands/init.lua` to call `vim.ui.open`, warning when a URL is unavailable (e.g. CSES has no standings). Closes #315.
This commit is contained in:
parent
b959f29bd4
commit
7bf4cf2538
8 changed files with 65 additions and 2 deletions
|
|
@ -606,6 +606,8 @@ class AtcoderScraper(BaseScraper):
|
|||
contest_id=contest_id,
|
||||
problems=problems,
|
||||
url=f"https://atcoder.jp/contests/{contest_id}/tasks/{contest_id}_%s",
|
||||
contest_url=f"https://atcoder.jp/contests/{contest_id}",
|
||||
standings_url=f"https://atcoder.jp/contests/{contest_id}/standings",
|
||||
)
|
||||
except Exception as e:
|
||||
return self._metadata_error(str(e))
|
||||
|
|
|
|||
|
|
@ -223,6 +223,8 @@ class CodeforcesScraper(BaseScraper):
|
|||
contest_id=contest_id,
|
||||
problems=problems,
|
||||
url=f"https://codeforces.com/contest/{contest_id}/problem/%s",
|
||||
contest_url=f"https://codeforces.com/contest/{contest_id}",
|
||||
standings_url=f"https://codeforces.com/contest/{contest_id}/standings",
|
||||
)
|
||||
except Exception as e:
|
||||
return self._metadata_error(str(e))
|
||||
|
|
|
|||
|
|
@ -218,6 +218,8 @@ class CSESScraper(BaseScraper):
|
|||
contest_id=contest_id,
|
||||
problems=problems,
|
||||
url="https://cses.fi/problemset/task/%s",
|
||||
contest_url="https://cses.fi/problemset",
|
||||
standings_url="",
|
||||
)
|
||||
|
||||
async def scrape_contest_list(self) -> ContestListResult:
|
||||
|
|
|
|||
|
|
@ -42,6 +42,8 @@ class MetadataResult(ScrapingResult):
|
|||
contest_id: str = ""
|
||||
problems: list[ProblemSummary] = Field(default_factory=list)
|
||||
url: str
|
||||
contest_url: str = ""
|
||||
standings_url: str = ""
|
||||
|
||||
model_config = ConfigDict(extra="forbid")
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue