natew / obtvse

Deprecated: See natew/obtvse2
http://github.com/natew/obtvse2
MIT License
1.38k stars 261 forks source link

[Refresh] 3 (possible) bugs #115

Closed astockwell closed 11 years ago

astockwell commented 11 years ago

First off, I'm pretty new to RoR, but have been a longtime php dev, so I'm submitting these as "possible" bugs, since I may not fully grasp how the app functions or may have a missed a config step, etc.

Love the project and your work, as I downloaded the refresh branch and have been playing with it, I've noticed 3 bugs.

1) At /admin, When you begin typing your "idea" (title), and you arrive at /new, once the page attempts to save (via js), rails throws a route error: ActionController::RoutingError (No route matches [PUT] "/3/edit")

The fix is in edit.js, the path is incorrect:

--- a/app/assets/javascripts/admin/edit.js
+++ b/app/assets/javascripts/admin/edit.js
@@ -191,7 +191,7 @@ function savePost(callback) {

       // If we just finished creating a new post
       if (!state.post) {
-        setFormAction('/edit/' + data.id);
+        setFormAction('/' + data.id);
         setFormMethod('put');
       }

2) Once that's fixed, if you

  1. repeat those steps again (goto /admin, begin typing new post title, routed to /new),
  2. then type some more so it registers and saves your post,
  3. then press the "back" button at the top of the left navigation column to return to /admin,
  4. wait a few seconds with the js console open, and ...

Javascript will throw an error and silently stop working. I've gotten it to throw two different errors: Cannot call method 'removeClass' of undefined on line 187 of admin/edit.js and Cannot call method 'addClass' of undefined ... save on line 171 of admin/edit.js (which I assume save is the el.save obj).

Unfortunately I haven't dug in enough to understand the event flow and thus how to fix these.

3) In the content editor the 'Return' key doesn't work, no way to insert a new line!

The fix is in keyboard.js:

--- a/app/assets/javascripts/admin/keyboard.js
+++ b/app/assets/javascripts/admin/keyboard.js
@@ -83,10 +83,11 @@ $(window)
       switch (e.which) {
         // Enter
         case 13:
-          if (!state.beganEditing) {
-            e.preventDefault();
-            el.content.focus();
-          }
+          break;
         // Cmd
         case 91:
           key.cmd = true;

I searched the project and it doesn't look like the beganEditing property is being used anywhere (again, unless I'm missing something), so I removed the preventDefault.

Please let me know if this is helpful at all, or if I'm off base. I can submit pull req's for #'s 1 and 3 if it would help.

natew commented 11 years ago

Thanks for these. Going to look into them tonight and push some stuff up. Feel free to send a pull request as well.

astockwell commented 11 years ago

No worries, I will try to get a pull request together tonight as well.

P.S. I believe this also fixes Issue #81

natew commented 11 years ago

Still need to look into the error, but marking this closed for now