-
Notifications
You must be signed in to change notification settings - Fork 162
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Lots of changes. Add JavaScript tests for the comment_form.js module.
- Loading branch information
Showing
40 changed files
with
1,579 additions
and
709 deletions.
There are no files selected for viewing
This file contains 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 |
---|---|---|
@@ -1,3 +1,12 @@ | ||
{ | ||
"presets": ["@babel/preset-env", "@babel/preset-react"] | ||
} | ||
"presets": ["@babel/preset-env"], | ||
"plugins": [ | ||
["@babel/plugin-transform-runtime"] | ||
], | ||
|
||
"env": { | ||
"test": { | ||
"plugins": ["transform-es2015-modules-commonjs"] | ||
} | ||
} | ||
} |
This file contains 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,39 @@ | ||
# https://editorconfig.org/ | ||
|
||
root = true | ||
|
||
[*] | ||
indent_style = space | ||
indent_size = 4 | ||
insert_final_newline = true | ||
trim_trailing_whitespace = true | ||
end_of_line = lf | ||
charset = utf-8 | ||
|
||
# Docstrings and comments use max_line_length = 79 | ||
[*.py] | ||
max_line_length = 80 | ||
|
||
# Use 2 spaces for the HTML files | ||
[*.html] | ||
indent_size = 2 | ||
|
||
# The JSON files contain newlines inconsistently | ||
[*.json] | ||
indent_size = 2 | ||
insert_final_newline = ignore | ||
|
||
# Minified JavaScript files shouldn't be changed | ||
[**.min.js] | ||
indent_style = ignore | ||
insert_final_newline = ignore | ||
|
||
# Makefiles always use tabs for indentation | ||
[Makefile] | ||
indent_style = tab | ||
|
||
[docs/**.rst] | ||
max_line_length = 79 | ||
|
||
[*.yml] | ||
indent_size = 2 |
This file contains 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,10 @@ | ||
**/*.min.js | ||
django_comments_xtd/static/django_comments_xtd/dist/* | ||
docs/_build/**/*.js | ||
node_modules/**.js | ||
js_tests/**/*.js | ||
venv/**/*.js | ||
demos/project-stories/psenv/**/*.js | ||
webpack.config.js | ||
**/webpack.config.js | ||
Gruntfile.js |
This file contains 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,41 @@ | ||
{ | ||
"parserOptions": { | ||
"sourceType": "module", | ||
"ecmaVersion": 8 | ||
}, | ||
"rules": { | ||
"camelcase": ["off", {"properties": "always"}], | ||
"comma-spacing": ["error", {"before": false, "after": true}], | ||
"curly": ["error", "all"], | ||
"dot-notation": ["error", {"allowKeywords": true}], | ||
"eqeqeq": ["error"], | ||
"indent": ["error", 4], | ||
"key-spacing": ["error", {"beforeColon": false, "afterColon": true}], | ||
"linebreak-style": ["error", "unix"], | ||
"new-cap": ["off", {"newIsCap": true, "capIsNew": true}], | ||
"no-alert": ["off"], | ||
"no-eval": ["error"], | ||
"no-extend-native": ["error", {"exceptions": ["Date", "String"]}], | ||
"no-multi-spaces": ["error"], | ||
"no-octal-escape": ["error"], | ||
"no-script-url": ["error"], | ||
"no-shadow": ["error", {"hoist": "functions"}], | ||
"no-underscore-dangle": ["error"], | ||
"no-unused-vars": ["error", {"vars": "local", "args": "none"}], | ||
"no-var": ["error"], | ||
"prefer-const": ["error"], | ||
"quotes": ["off", "single"], | ||
"semi": ["error", "always"], | ||
"space-before-blocks": ["error", "always"], | ||
"space-before-function-paren": ["error", {"anonymous": "never", "named": "never"}], | ||
"space-infix-ops": ["error", {"int32Hint": false}], | ||
"strict": ["error", "global"] | ||
}, | ||
"env": { | ||
"browser": true, | ||
"es6": true | ||
}, | ||
"globals": { | ||
"django": false | ||
} | ||
} |
This file contains 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
84 changes: 0 additions & 84 deletions
84
demos/project-stories/project_stories/templates/base.html.py
This file was deleted.
Oops, something went wrong.
This file contains 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 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
46 changes: 0 additions & 46 deletions
46
demos/project-stories/project_stories/templates/homepage.html.py
This file was deleted.
Oops, something went wrong.
This file contains 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
67 changes: 0 additions & 67 deletions
67
demos/project-stories/project_stories/templates/users/account.html.py
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
3618f6b
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.
Wow, nice to see the new version is in active development! I just tried the 3.0.0 demo and it works, but ajax doesn't work (it's a work in progress I guess?). Based on the commit, it seems like the new ajax version will not require any dependencies like ReactJS or jQuery. Do you rewrite it in vanilla js?
Thank you for your work, I imagine how much time it takes to maintain the project!
3618f6b
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.
Thank you :-)
There is a demo project directory that should go away as it's outdated (
demo/project
), the two working projects aredemos/project-quotes
anddemos/project-stories
. The first doesn't use JavaScript, and the second does use the JavaScript code. Check that one. Everything works there. There are README.md files in both to set them up. What is missing yet is a battery of tests for the reply-forms.js and reactions.js module. The JavaScript tests added in this commit only test the comment-form.js module.About the JavaScript plugin, yes, it's just Vanilla JavaScript. I develop a lot lately with TypeScript and React but I think django-comments-xtd should use a Vanilla approach by default, without any framework. Maybe it can be extended with a React plugin or whatnot with an external package.
3618f6b
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.
@jdbit, the README.md of
demos/project-stories
now explains how to load the fixtures and what users you can use to test the project.3618f6b
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.
Thank you for your response! I just tried
demos/project-stories
, but it's still not ajax. The browser console says it can't find/static/django_comments_xtd/dist/dcx-3.0.0.js
and it seems like this file doesn't exist anywhere in the project. Where can I find it?3618f6b
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.
Oh, sorry for that. It has to be built.
I just added it. Thanks for telling :-)
3618f6b
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.
Haha, thank you, everything works now;) Just 4kb gzipped, I'm so glad you decided to make it vanilla js! The new default design is very nice too, however, I think these reply fields complicate the design and take too much space. Maybe it would be better to replace these inputs with just a link button near the React button (example here)? Just like threaded comments on Reddit. It's just a feedback, not trying to add you even more work:) Anyway, I'll try to make it on my own.
I think I can already use the new version in production. Can I migrate from the v.2.9 with existing comments in the db without losing the comments? It seems like you only added tables for reactions, the XtdComment model was untouched.
3618f6b
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.
Thank you for your feedback, I really appreciate it.
The problem with Reddit is that the reply dialog always displays immediately below the comment you click to reply.
So comments are ordered from more recent date to older ones, that's difficult to read. I mean, it's not in sequence.
Nevertheless I will keep it in mind.
You are brave if you want to use it in production, I guess it will work without problems, actually v3 has more tests than the previous versions. Indeed, the model XtdComment does not change, only the Reaction model and the related tables. But if you had Like/Dislike CommentFlags in your app, it won't work with Reactions. I have not done yet any migration command.
Thanks again a lot for your feedback :-)
3618f6b
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 see now.
It's for my own small websites, so should not be a big issue if something goes wrong.
Thank you for your help and the great commenting app for Django!