claudioc / jingo

Node.js based Wiki
MIT License
1.02k stars 184 forks source link

Can Jingo import existing markdown files? #184

Closed yusiwen closed 7 years ago

yusiwen commented 7 years ago

I've just started using Jingo as a note-taking application and it looks great. Thanks for your work.

I've wrote a lot of markdown files as my notes these years, and use git to save them. When I set up Jingo, I pointed application.repository to this notes repo, and there was no page after I started Jingo server and logged in. It asked me to create the first page. After creating the page, a new markdown file was created in my notes repo along with a new commit in git. It seems that Jingo just ignored the existing files in my repo.

My question is: Can I import whole my notes (already in markdown file format) into Jingo?

Thanks.

claudioc commented 7 years ago

Hi,

not sure what went wrong there, because Jingo has been made exactly for the use case you're mentioning: having an existing set of markdown files that you want to view/edit from a web interface.

There's probably just a configuration problem there, or something else that I don't actually understand :)

If you don't have a Home.md file, Jingo will try to create it (it needs an index page, after all). If you want to use another page as the index file, then try setting the pages.index configuration option.

yusiwen commented 7 years ago

@claudioc Thanks for reply.

I've tried many times. After I pointed application.repository to my existing notes repo, Jingo asked me to create a "Home" page. After creating it, there are some pages appearing in "All pages", but these pages are only whose names are single word, for example: one of my notes file is "Misc.md", it can be shown in the "All pages"; other files, like "Git - Tips and Notes.md", can't be find in "All pages".

Edit: Confirmed. All my note files with single word in file name are shown in "All pages", other files can't.

yusiwen commented 7 years ago

@claudioc I've finally figured out the problem: the names of my note files. When I changed my note file name, e.g. "Git - Tips and Notes.md" to "Git-Tips-and-Notes.md" and committed that change, Jingo shown that file in "All pages".

Is there some convention of file name?

claudioc commented 7 years ago

Ah yes, of course. As Gollum does (the inspiration for Jingo), Jingo uses the "-" as the word separator for page name (which are used for the file name).

Unfortunately at the moment this is not a configurable option :(

Sorry about that.

yusiwen commented 7 years ago

@claudioc Tha't ok. I've just wrote a shell script to rename all my files into this convention, and they are all shown in the page now.

Unfortunately, there is another problem here. The search result can not show the right file name.

I've a screenshot below: screenshot-2016-12-08 17-18-26

As you can see, all the search results are start with "Git:XX" (XX is line numbers perhaps), and the link is incorrect, because it links me to "myhost/wiki/Git?hl=rebase" and the page doesn't exist, so Jingo will open a new page named "Git" for me. The right file name may be "Git.Tips-and-Notes.md".

yusiwen commented 7 years ago

OK, I found the problem causing search results missing file name parts.

In routes/search.js: line 49: pageName: path.basename(record[0].split(".")[0]), it is not very friendly with the files whose name has '.' (dot) before '.md' extension. So, I changed it to record[0].split(".md")[0], and it works.

claudioc commented 7 years ago

Thanks, I will apply this fix to the next release :)