-
Notifications
You must be signed in to change notification settings - Fork 61
monographs: add slug field which regenerates on republish #72
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
01zulfi
wants to merge
5
commits into
streetwriters:master
Choose a base branch
from
01zulfi:monograph/editable-url
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 2 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
2697a65
monographs: add slug field which regenerates on update
01zulfi 6904139
monographs: don't regenerate slug on update
01zulfi e1261fe
common: fix monograph public url constant
01zulfi 1e61752
monographs: improve APIs && use .Project when fetching monographs
01zulfi c97652d
monographs: reinstate analytics endpoint
01zulfi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| /* | ||
| This file is part of the Notesnook Sync Server project (https://notesnook.com/) | ||
|
|
||
| Copyright (C) 2023 Streetwriters (Private) Limited | ||
|
|
||
| This program is free software: you can redistribute it and/or modify | ||
| it under the terms of the Affero GNU General Public License as published by | ||
| the Free Software Foundation, either version 3 of the License, or | ||
| (at your option) any later version. | ||
|
|
||
| This program is distributed in the hope that it will be useful, | ||
| but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| Affero GNU General Public License for more details. | ||
|
|
||
| You should have received a copy of the Affero GNU General Public License | ||
| along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| */ | ||
|
|
||
| using Notesnook.API.Models; | ||
| using Streetwriters.Common; | ||
|
|
||
| namespace Notesnook.API.Extensions | ||
| { | ||
| public static class MonographExtensions | ||
| { | ||
| public static string ConstructPublishUrl(this Monograph monograph) | ||
| { | ||
| var baseUrl = Constants.MONOGRAPH_PUBLIC_URL; | ||
| return $"{baseUrl}/{monograph.Slug ?? monograph.ItemId}"; | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm still contemplating if we need to add this check. On one hand, I think it makes sense to restrict fetching monograph by id if the slug exists. On another hand, if a user's client app is a bit behind (i.e. doesn't have the slug property yet), they'll be shown the monograph link with the id which will be a 404 causing confusion
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if we use a different endpoint for monographs with slug? It'll prevent a lot of bugs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The public get monograph API is only called on the monograph frontend. I'm trying to understand how having a separate API to fetch by id and slug is beneficial
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
True but if we use separate URL on the frontend for slugs, we can easily route users based on that. It will bring clarity and prevent doing extra work every time a slug is not matched. It still won't fix this though:
Unless we allow both to work.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
created a separate endpoint for getting monographs by slug
also, in the get monography by Id endpoint, I'm not checking for slug anymore