SUMMARY
REST API for gist creation uses JSON for payload format, which
supports array. Form doesn't so gist file field names(filename and
content) follow {KNOWN_PREFIX}{index} semantics, which can be parsed
while processing request.
SUMMARY
Authenticated and unauthenticated users have different requirements.
Links to profile and settings are irrelevant for unauthenticated
users. So separate navigation bars.
USAGE
crate::pages::auth_ctx
Authenticated user context should be supplied on every
authenticated route template render. Authenticated navigation
bar depends on "loggedin_user" to render profile link.
AUTH_NAV("auth_nav")
Should only be used in authenticated routes. Depends on
"loggedin_user" authenticated user context, which can't be
supplied in unauthenticated routes.
NOTES
Currently, there's (template)code
duplication, when inheritance for "include" templates are
implemented in Tera crate, navigation bars implementations should be
refactored to avoid duplication.
SUMMARY
Browsers send empty strings for empty fields in form submissions.
Email is optional in registration process but empty field fails
validation for email and results in 400 bad request. Converting
empty strings to None fixes this.
SUMMARY
crate::errors::ServiceError is for JSON APIs.
crate::page::errors::PageError is implemented for HTML pages. It
takes a template and ServiceError instance to render given template
with error message.
If a user submits a form, which errors out, the user should be
presented the same form, values filled but with error message
included.
DESCRIPTION
PageError::reason is human readable and friendly message
explain what had happened.
PageError::title is the name of the status code: HTTP "200: is "200
OK"
crate::page::errors::CtxError: trait all templates that can error
should implement. It accepts an error and appends it to the
templates context before rendering it.
SUMMARY
New field is added to settings to receive email of the admin of the
instance. source_code is a link to the repository of the source code
of a GitPad instance, set_source_code is defined to build a HTTP
link to the exact commit from which the instance binary was built.
NOTE
Current Settings::set_source_code assumes the provided HTTP link to
point to a forge belonging to the GitHub-family(GitHub, Gitea and
GitLab), provisions must be made to accommodate other forges as
well.
DESCRIPTION
Each comment is uniquely identified by database assigned, serially
incremented ID. Access controlled REST endpoint is added to delete
comment by ID.
ERRORS RETURNED
- Gist doesn't exist: 404 GistNotFound
- Gist is private and requesting user is not owner or is not visible
to user: 404 GistNotFound
- Gist exists and is visible to requesting user but comment doesn't
exist: 404 CommentNotFound
- Gist exists and is visible to requesting user is not comment owner
: 401 UnauthorizedOperation
DESCRIPTION
Get all comments on a gist. Access controlled but optionally
authenticated HTTP REST endpoint is added to get comment by ID.
ERRORS RETURNED
- Gist doesn't exist: 404 GistNotFound
- Gist is private and requesting user is not owner or is not
authenticated: 404 GistNotFound
DESCRIPTION
Each comment is uniquely identified by database assigned, serially
incremented ID. Access controlled but optionally authenticated HTTP
REST endpoint is added to get comment by ID.
ERRORS RETURNED
- Gist doesn't exist: 404 GistNotFound
- Gist is private and requesting user is not ower or is not
authenticated: 404 GistNotFound
- Comment is empty: 400 EmptyComment
- Gist exists and is visible to requesting user but comment doesn't
exist: 404 CommentNotFound
SUMMARY
Comment on gist and utilities to generate post comment REST
endpoint route from username and gist public ID component
ERRORS
- Gist doesn't exist, 404 GistNotFound is returned
- Gist is private and commenting user is not ower, 404 GistNotFound
is returned
- Comment is empty, 400 EmptyComment is returned