Giter Site home page Giter Site logo

Markdown in body about quokka HOT 7 CLOSED

quokkaproject avatar quokkaproject commented on May 8, 2024
Markdown in body

from quokka.

Comments (7)

avelino avatar avelino commented on May 8, 2024

👍

from quokka.

rochacbruno avatar rochacbruno commented on May 8, 2024

👍
Great!

We need to implement that in a way the editor can choose the input format. SO in the Post we need to add a field format and defaults it to DEFAULT_FORMAT settings.

A dropdown in admin Post page will switch format and the editor, so we can support HTML, Creole, Markdown, .rst and also custom formats.

from quokka.

jonasteuwen avatar jonasteuwen commented on May 8, 2024

But the channels can have some content as well, right? Are such properties not better part of the object itself (the body) rather than the post? Perhaps as an EmbeddedDocument, as I assume that 'flat' is faster in MongoDB (but I am by no means an expert).

from quokka.

rochacbruno avatar rochacbruno commented on May 8, 2024

I was thinking in adding content_format in the Post class https://github.com/pythonhub/quokka/blob/master/quokka/modules/posts/models.py#L8

DEFAULT_FORMAT = "html"
FORMAT_CHOICES = ("html", "rst", "creole", "markdown", "latex")

class Post(Content):
    body = db.StringField(required=True)
    format = db.StringField(choices=FORMAT_CHOICES, default=DEFAULT_FORMAT)

So it would be used directly in template to render the content within a template filter

{{ post.body | format_content(post.format) }}

or maybe we can define content_parser as a method of Post class

{{ post.parsed_body }}

Also for the textarea in Flask-Admin we will need to write a customized widget, which will be lazy (have to check if tinymce supports lazy binding). So inside the admin just switch from available formats and the JS editor changes from tinymce, lepture, creoleeditor etc...

What are the details of implementation you was thinking @jonasteuwen ? having body as an EmbeddedDocument? and inside it {'format': 'html', 'content': '<p>blabla</p>'}, will it be practical to implement the editor in admin?

from quokka.

rochacbruno avatar rochacbruno commented on May 8, 2024

BTW: Channels are not meant to have content body only a description to be used is a list of channels, channels are just content aggregates, just like categories or folders. We can add Posts or another contents inside it, so I think we can have it only for Post. What do you think?

For new modules, if the Model needs a "body" and a "format" only need to inherit Post directly, other contents can inherit Content.

from quokka.

jonasteuwen avatar jonasteuwen commented on May 8, 2024

A lot of information!

The idea is good, I have yet to get a bit accustomed to channels/posts as the latter have .html extension, which is not my preference (but, different topic!)

It sounds good, but I would prefer if we do not need to define the parser in the template, the template should just get html. If the parser is set in the document, we can already parse out html right?

class Body(db.EmbeddedDocument):
    body = ...
    parser = ...

    def __unicode__(self):
        return parsed_body()

Or something similar, as the body should in my opinion consist of: the content, a set of rules on how to read it. Of course, it will look the same in the database so I might be missing something or be too idealistic. The main point is that once you put it in a template, it should be already parsed into html for a browser, or json for the api, etc.

All this aside, we should make sure, we do not do work that would have been done differently if we were to also implement something like createjs.org :-).

from quokka.

rochacbruno avatar rochacbruno commented on May 8, 2024

Implemented!

from quokka.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.