zackmdavis / Finetooth

an experimental discussion forum
MIT License
2 stars 0 forks source link

comment reply links don't work on user pages #22

Open zackmdavis opened 10 years ago

zackmdavis commented 10 years ago

probably because the "Reply" link doesn't have the data-post-pk attribute set, probably because the template fragment is making assumptions about its context that aren't true on user profile pages

cookjw commented 10 years ago

Actually, I'm currently finding that they don't work anywhere else either...

cookjw commented 10 years ago

I think I'm going to need to first understand why this code (from templates/includes/comment.html):

<a href="javascript:void(0);" class="comment-tool" data-comment-pk="{{ comment.pk }}" data-post-pk="{{ post.pk }}">

doesn't constitute "setting the data-post-pk attribute".

zackmdavis commented 10 years ago

Works for me on e8605da4. You surely have internet access, because you posted the above comments (it's loading jQuery from a CDN rather than locally). I don't imagine you're using Internet Explorer 8, are you? (I chose jQuery 2.1 for the same reason I chose Python 3.4.)

why this code [...] doesn't constitute "setting the data-post-pk attribute".

Well, it does if there's a post variable in the context from which the template is getting rendered. But if not, then the actually rendered HTML looks like this (I think you can configure Django to raise an error instead of using the empty string when you try to use an undefined variable in templates, but I have not done so)—

 <a href="javascript:void(0);" class="comment-tool reply-form-link"
     data-comment-pk="2" data-post-pk="">
zackmdavis commented 10 years ago

You probably need to git pull; I broke the comment forms in 151698e9 (September 13) and fixed them in 8df4a86b (September 14).

zackmdavis commented 10 years ago

(See now-closed Issue #13)

cookjw commented 10 years ago

When I did this it said I was up-to-date. (OTOH, I've been getting weird inconsistent behavior of various sorts, so maybe I'll just try it again later.)

On Wednesday, September 24, 2014, Zack M. Davis notifications@github.com wrote:

You probably need to git pull; I broke the comment forms in 151698e https://github.com/zackmdavis/Finetooth/commit/151698e91f3945e0b1876681a384903bb06d2c25 (September 13) and fixed them in 8df4a86 https://github.com/zackmdavis/Finetooth/commit/8df4a86bfed08f42ee6c57660aad90d3f0bbfb25 (September 14).

— Reply to this email directly or view it on GitHub https://github.com/zackmdavis/Finetooth/issues/22#issuecomment-56767513.

zackmdavis commented 10 years ago

What branch (git status) and commit SHA (first hash in git log) are you on? What kind of weird inconsistent behavior?

As humans, it's hard to resist the temptation to anthropomorphize our creations—we desperately want to say, "Oh, the program is behaving weirdly right now; maybe I'll reboot and try again later and the problem will go away," as if the machine were a dog in a passing bad mood. But as you know—as I have so much trouble remembering—it is wrong! A deterministic program given the same inputs will return the same outputs; weird, inconsistent behavior is in the map, not the territory. True, as fake programmers living in a fake world that calls itself Python, our experience is built on so many layers of tools built on tools built on tools that sometimes small imperfections in the underworld manifest themselves as strange happenings that we can't explain. But in this repository, we are not exactly debugging compilers or mounting massive multithreaded scaling in the Cloud. This is a vanilla Django project with seventy-five commits by two authors! We are as gods here! Bugs are not a fact of life to be reluctantly accepted, but a menace to be understood and reengineered out of existence!

Because if we can't live up to our responsibilities as gods here, how will we cope with a real-world setting where the bug is lurking somewhere in hundreds of thousands of lines of code by dozens of developers, when real customers bearing real money are breathing down our backs waiting for us to make the contemptible thing work—and waiting only until their patience wears thin and they take the money to our competitors, leaving us alone to starve and die in the cruel Darwinian jungle-marketplace?

cookjw commented 10 years ago

probably because the "Reply" link doesn't have the data-post-pk attribute set

Alas, this doesn't seem to be the (sole) issue: in 82229aa790 I set it to something that actually exists (namely comment.post.pk as opposed to post.pk), as verified both by configuring Django to complain when a template variable is nonexistent and by looking at the HTML source, but the behavior is the same (when you click on the "Reply" link, it pretends you didn't).

zackmdavis commented 10 years ago

On further investigation, it turns out that this is actually because the click-handler isn't getting set at all because a6dd1bbe changed setCommentFormShowHandlers to only trigger the form appearance when there's a click event on elements with the reply-form-link class that are descendants of an element with the id comments, and there isn't anything with a comments id in profile.html.

I think the posts/comments display on the user profile page could use a lot of work anyway (I kind of prefer reverse-cronological order over everything rather than all comments followed by all posts), so this is probably something to keep in mind when reworking that rather than something to fix now. (And, come to think of it, some might argue that you shouldn't even be allowed to reply from a user profile page, where you might be deprived of the full context of the discussion---I think some websites we know are like that.)