mgaitan / waliki

A wiki engine powered by Django and Git
http://waliki.pythonanywhere.com
BSD 3-Clause "New" or "Revised" License
309 stars 56 forks source link

Initial edit not saving #146

Open bitstein opened 7 years ago

bitstein commented 7 years ago

I am reposting this from the Google Group email list (original here):

Hey guys,

I was very happy to find Waliki. It looks like a really promising project with many of the features I'd like in a wiki. When setting up a basic site as per the README, I came across some interesting behavior. When I create a new page, the empty markdown file is created, but I am unable to save the file after an initial edit. Interestingly, when I went into the Waliki source code and made an edit to views.py, I was able to make things function fine. What I did was change the raw page value here (https://github.com/mgaitan/waliki/blob/master/waliki/views.py#L125) from an empty string to a single space (" "). This saved the file as such (a single space, rather than empty), and the form submission worked fine after. I'd of course prefer if the file was initially saved as empty.

Do you know why this might be happening?

Thanks, Michael

rudyryk commented 6 years ago

Seems like there's a JavaScript error, I get the following message in debug console:

An invalid form control with name='raw' is not focusable.

screen shot 2017-11-03 at 16 28 09
rudyryk commented 6 years ago

As I can understand because of this bug new pages creation is completely broken at the moment.

l-dfa commented 6 years ago

Hi all,

trying ver 0.9.dev0, creating a new page using reStructuredText I get the error:

...
Django Version:     2.0.2
Exception Type:     AttributeError
Exception Value:'ReStructuredTextMarkup' object has no attribute 'get_document_body'
Exception Location:     C:\Dati\Studio\Sviluppi\Unavox\venv\lib\site-packages\waliki\models.py in _get_part, line 135
...

Is this the same kind of error from Michael?

maybe something broken in _markups.py inheriting from MarkdownMarkupBase ?

thank you ldfa

frenchbeard commented 5 years ago

@bitstein The reason for this behaviour (the creation issue) seems to lie with git, which doesn't care about an empty file (if you only "touch" a file of size zero in a git repo, it won't be tracked, even less staged, so the database contradicts the git repository information). @l-dfa There seems to be an issue in the way the body is fetched in models.py : currently, through

Page._get_part(self, part)

which results in a call to

getattr(self.markup_, 'get_document_body')(self.raw)

when the get_document_body only exists as a result in Converted[MarkupName], which would be the markup.ConvertedReStructruredText for your case, so more something like that

 getattr(self.markup_.convert(self.raw), 'get_document_body')

There was also a missing parameter in the signal sent on page_saved, but I have to dig into that. I made a mess of a commit fixing a couple of things and readying it for python3, but the pdf generation still requires python2 (rst2pdf being how it is).