Bug 730707 kumascript #164

Merged
merged 16 commits into from Apr 20, 2012

Conversation

Projects
None yet
3 participants
Member

lmorchard commented Apr 18, 2012

Opening another PR for this, whether it's "done" or not. I've got quite a number of unreviewed commits piled up.

lmorchard added some commits Mar 19, 2012

bug 730707: progress checkpoint
* Switch back to out-of-box <% %> EJS escape sequences instead of {% %},
  since the ACE editor interferes with that less and the EJS docs make
  more sense that way.

  * TODO: Maybe need a schematic migration to convert existing templates
    in dev boxes at least:

      update wiki_document
      set html=replace(replace(html, '{%', '<%'), '%}', '%>')
      where slug like '%Template:%';

      update wiki_revision
      set content=replace(replace(content, '{%', '<%'), '%}', '%>')
      where slug like '%Template:%';

* Don't process views of Template:* pages through KumaScript

* Don't apply Bleach to Template:* source

* Reduce required length of page title to 2, so "en" and "CSS" can be
  edited.

* Whitelist a few more elements used in pages for Bleach.

* Add more elements with style attribute allowed by Bleach, whitelist a
  bunch of inline styles used in existing pages.

* Improvements to kumascript error display, broken out into an include.
  Includes edit / new links for Template documents behind scripts.

* Enable plain-text syntax highlighter brush

* KumaScript update
bug 730707: Rework section ID generation
* More closely match MindTouch for generating anchor IDs in pages, to
  help prevent breaking intra-wiki anchor links

* Honor an explicit autogenerated ID override where the `name` attribute
  is present. That should help break fewer page anchor links on existing
  pages.
bug 730707: Bugfix for macro migration
* Bugfix for macro migration, where markup appears in the middle of a
  parameter. This happens in a lot of `note` and `warning` macros.
bug 730707: Title is not unique on documents.
* Remove vestigal title uniqueness enforcement that caused DB errors
bug 730707: Send doc metadata to kumascript
* Kumascript now accepts env vars as headers with base64/utf8/JSON
  encoded data structures

* Assemble some env vars from document metadata to send in the request
  to kumascript
@@ -102,6 +116,10 @@ def gen_id(self):
self.known_ids.add(id)
return id
+ def slugify(self, text):
+ """Turn the text content of a header into a slug for use in an ID"""
+ return (text.replace(' ', '_'))
@ubernostrum

ubernostrum Apr 19, 2012

Contributor

Is there any chance these IDs ever end up as part of a URL (not just a fragment identifier)? Looks like they do further down and if so, that's a potential Unicode issue -- we might want to do something like Django's own built-in slugify template filter, which has a little Unicode-normalization song-and-dance to produce a readable but URL-safe result.

@lmorchard

lmorchard Apr 19, 2012

Member

Yeah, these will probably end up in section editing URLs. :/ Need to look at this some more, because I want to make sure it matches up with existing anchor links from MindTouch. I don't think it quite does that all the way, either.

+ body='HELLO WORLD',
+ headers={}
+ )
+ mock_requests_get.side_effect = my_requests_get
@groovecoder

groovecoder Apr 19, 2012

Owner

why side_effect here?

@lmorchard

lmorchard Apr 19, 2012

Member

That's how my_requests_get gets called, and the headers trapped.

@@ -39,7 +41,7 @@
initMetadataEditButton();
initSaveAndEditButtons();
initArticlePreview();
- initTitleAndSlugCheck();
+ // initTitleAndSlugCheck();
@groovecoder

groovecoder Apr 19, 2012

Owner

just comment? should we delete altogether?

@lmorchard

lmorchard Apr 19, 2012

Member

Might be worth deleting... I just wanted to turn it off for now, and look into properly fixing it in the future. It's not updated for the Kuma world where locale + slug are unique rather than title + slug

+ # happen in a case like <h1><h1></h1></h1>. But, that's
+ # invalid markup and the worst case should be a
+ # truncated ID because all the text wasn't accumulated.
+ break
@ubernostrum

ubernostrum Apr 20, 2012

Contributor

This may be a silly question, but the comment here made me think of it: is there any mechanism enforcing uniqueness of IDs within the document? What happens if IDs end up colliding?

@lmorchard

lmorchard Apr 20, 2012

Member

I kind of punted on that... There is a mechanism for uniqueness, but only for auto-generated IDs (eg. sect1, sect2, etc). For IDs based on element text or the name attribute, no uniqueness is enforced.

This is really a half-baked feature, ugh. :/

@lmorchard

lmorchard Apr 20, 2012

Member

FWIW, I just filed bug 747403 to remember to put more work into this feature

Member

lmorchard commented Apr 20, 2012

Is there anything more to do or review here before merging?

Owner

groovecoder commented Apr 20, 2012

oh no I just forgot to merge it.
On Apr 20, 2012 3:26 PM, "Les Orchard" <
reply@reply.github.com>
wrote:

Is there anything more to do or review here before merging?


Reply to this email directly or view it on GitHub:
#164 (comment)

groovecoder added a commit that referenced this pull request Apr 20, 2012

@groovecoder groovecoder merged commit d7f420a into mozilla:master Apr 20, 2012

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment