Skip to content

Commit

Permalink
edit mtgdoc page, document generic links
Browse files Browse the repository at this point in the history
  • Loading branch information
lunakv committed Sep 17, 2022
1 parent 9c922d2 commit bb8759a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
12 changes: 9 additions & 3 deletions app/routers/link.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
from fastapi import APIRouter, Response
from fastapi.responses import RedirectResponse
from ..utils import db
from ..utils.models import Error
from ..utils.remove422 import no422

router = APIRouter(tags=["Redirects"])

Expand Down Expand Up @@ -36,14 +38,18 @@ async def jar_link():
"""
return RedirectResponse(await db.get_redirect("jar"))

class LinkError(Error):
resource: str

@router.get("/{resource}", include_in_schema=False)
@no422
@router.get("/{resource}", status_code=307, summary="Other links", responses={307: {"content": None}, 404: {"description": "Link to resource does not exist.", "model": LinkError}})
async def other_link(resource: str, response: Response):
"""
Catchall route for other random undocumented redirects (e.g. AIPG)
Catchall route for other unofficial or undocumented redirects (e.g. the AIPG).
See <https://mtgdoc.link> for the full list of supported values.
"""
url = await db.get_redirect(resource)
if url:
return RedirectResponse(url)
response.status_code = 404
return {"detail": "Not found"}
return {"detail": "Not found", "resource": resource}
10 changes: 7 additions & 3 deletions mtgdoc.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,18 @@ <h1>This is the root of mtgdoc.link</h1>

<p>You can use any of the following resource names as either a path segment or a subdomain. For more information, see the Academy Ruins <a href="https://api.academyruins.com/docs#tag/Redirects">API docs</a>.

<p><b>Currently supported redirects:</b></p>
<p><b>Currently supported official documents:</b></p>
<ul>
<li><a href="https://mtgdoc.link/cr">CR</a></li>
<li><a href="https://mtgdoc.link/mtr">MTR</a></li>
<li><a href="https://mtgdoc.link/ipg">IPG</a></li>
<li><a href="https://mtgdoc.link/jar">JAR</a></li>
<li><a href="https://mtgdoc.link/aipg">AIPG (annotated IPG — unofficial)</a></li>
<li><a href="https://mtgdoc.link/amtr">AMTR (annotated MTR — unofficial)</a></li>
</ul>
<p><b>Other supported unofficial links:</b></p>
<ul>
<li><a href="https://mtgdoc.link/aipg">Annotated IPG [AIPG]</a></li>
<li><a href="https://mtgdoc.link/amtr">Annotated MTR [AMTR]</a></li>
<li><a href="https://mtgdoc.link/wpn">WPN Rules & Documentation Page [WPN]</a></li>
</ul>
</body>
</html>

0 comments on commit bb8759a

Please sign in to comment.