-
-
Notifications
You must be signed in to change notification settings - Fork 5.7k
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
directory support for wiki #8891
Conversation
+ add _delete to reserved keywords Signed-off-by: Michael Gnehr <[email protected]>
see #7225 for more details Signed-off-by: Michael Gnehr <[email protected]>
Signed-off-by: Michael Gnehr <[email protected]>
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've left some comments about the code (only the first couple of files).
The problem I see here (if I understand your intention correctly) is that existing wikis might become invalid after this code is implemented. And a migration process will be extremely difficult, since wikis contain links/references inside the pages and they must match the names of the documents (and page history will become useless).
Perhaps this could be implemented as optional for new repos, though, as those will contain no history.
); | ||
}, 0); | ||
|
||
let $toolbar = $(preview).closest('.CodeMirror-wrap').prev(); |
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.
let $toolbar = $(preview).closest('.CodeMirror-wrap').prev(); | |
const $toolbar = $(preview).closest('.CodeMirror-wrap').prev(); |
Suggestion by as per linter error.
func WikiNameToSubURL(name string) string { | ||
return url.QueryEscape(strings.Replace(name, " ", "-", -1)) | ||
// remove path up | ||
re1 := regexp.MustCompile(`(\.\.\/)`) |
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.
This should be simpler:
name = strings.ReplaceAll(name, "/../", "/")
(And TrimSuffix
/TrimPrefix
for /..
and ../
)
But strings starting with ../
, ending with /..
or containing /../
should be rejected as invalid instead of sanitized, IMHO.
name = strings.Trim(name, "\n\r\t /") | ||
name = url.QueryEscape(name) | ||
//restore spaces | ||
re3 := regexp.MustCompile(`(?m)(%20|\+)`) |
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.
Regexps that are not dynamic should be stored outside of the function to avoid compiling them multiple times. That also makes it easier to make a unit test for them.
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.
Anyway, return strings.ReplaceAll(name, "+", "%20")
should do the trick as well.
} | ||
for _, kv := range restore { | ||
loopRe := regexp.MustCompile(kv[0]) | ||
name = loopRe.ReplaceAllString(name, kv[1]) |
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.
See my other comments above.
} | ||
|
||
// FilenameToPathFilename converts a wiki filename to filename with filepath. | ||
func FilenameToPathFilename(name string) string { |
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.
import "net/url"
And you have net.PathEscape()
, net.PathUnescape()
.
@@ -136,6 +198,9 @@ func (repo *Repository) updateWikiPage(doer *User, oldWikiName, newWikiName, con | |||
} | |||
|
|||
gitRepo, err := git.OpenRepository(basePath) | |||
|
|||
fmt.Println(reflect.TypeOf(gitRepo)) |
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.
This should not be here
Yeah my intention was to support both, old links and new ones (if i remember correctly) -> so old links and paths should still be working. (I hope i don't missed too much cases) I will fix my own branch in the next few days so it will compile again. (if @LucasDLK isn't faster) |
This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs during the next 2 months. Thank you for your contributions. |
forked at PR #7390
This PR
files can exists in old and new structure.
files are selected by link, so it is possible to access and view both
writing to one of them will delete both, and create new one in directory structure
delete will delete the selected file
support images relative to directory path
fix preview on preview rendering
fix 500 error if wiki contains pages with invalid uri encoding (e.g. filename: badescaping%%.md)
ui fixes
add button 'Abort' to wiki edit and new page