librelist archives

« back to archive

Extension : Flask-CodeMirror

Extension : Flask-CodeMirror

From:
joachim trouverie
Date:
2013-12-02 @ 16:23
Hi all,

I was planning to use a field to write some source code (with syntax
highlighting, brackets match ... ) .

Is this kind of field already exists or should I create my own using an
external library like CodeMirror ?

Thanks in advance to read this.


-- 
TROUVERIE Joachim
Ingénieur développement
*MEDIWARE* <http://www.mediware.fr/>
*High Tech Buro, Bat C, rue Garance,*
* 31670 LABEGE Cedex*

Re: [flask] Extension : Flask-CodeMirror

From:
gioi
Date:
2013-12-02 @ 16:47
If you're writing a field, probably you're using an external form tool,
and so Flask-CodeMirror is not a well-suited name ;-)
In a 5-second research on PyPi [1] I couldn't find anything. So please
specify the library you're using (if any) and I would gladly help.

[1] https://crate.io/?has_releases=on&q=codemirror

Re: [flask] Extension : Flask-CodeMirror

From:
joachim trouverie
Date:
2013-12-02 @ 18:33
Hello,

Thanks for your answer.

Concerning the field I was thinking about using the extension Flask-WTF and
integrate it in a Flask app.

I begin to code something using wtform fields but I am not sure if it is
the best way to do it.




2013/12/2 gioi <g@gioi.tk>

> If you're writing a field, probably you're using an external form tool,
> and so Flask-CodeMirror is not a well-suited name ;-)
> In a 5-second research on PyPi [1] I couldn't find anything. So please
> specify the library you're using (if any) and I would gladly help.
>
> [1] https://crate.io/?has_releases=on&q=codemirror
>
>


-- 
TROUVERIE Joachim
Ingénieur développement
*MEDIWARE* <http://www.mediware.fr/>
*High Tech Buro, Bat C, rue Garance,*
* 31670 LABEGE Cedex*

Re: [flask] Extension : Flask-CodeMirror

From:
gioi
Date:
2013-12-02 @ 18:45
Il 02/12/2013 19:33, joachim trouverie ha scritto:
> Hello,
>
> Thanks for your answer.
>
> Concerning the field I was thinking about using the extension
> Flask-WTF and integrate it in a Flask app.
>
> I begin to code something using wtform fields but I am not sure if it
> is the best way to do it.
Why not? I think it is a nice idea ;-)
The only problem is: where are you going to put javascripts to integrate
with CodeMirror? I just have no idea on how to do it elegantly.
Right now, I would create a TextAreaField and then add the required
script to integrate CodeMirror in the template. Simple & efficient.

Re: [flask] Extension : Flask-CodeMirror

From:
joachim trouverie
Date:
2013-12-03 @ 08:07
I was thinking about using a CDN to host Javascript and load in the app
only languages filled by the user in config.

Concerning the Field, I created a subclass of TextAreaField using a
subclass of TextArea widget to integrate CodeMirror javascript code.

I'm still working on it and will post it on Pypi as soon as available.

Thanks a lot for your answers.


2013/12/2 gioi <g@gioi.tk>

> Il 02/12/2013 19:33, joachim trouverie ha scritto:
> > Hello,
> >
> > Thanks for your answer.
> >
> > Concerning the field I was thinking about using the extension
> > Flask-WTF and integrate it in a Flask app.
> >
> > I begin to code something using wtform fields but I am not sure if it
> > is the best way to do it.
> Why not? I think it is a nice idea ;-)
> The only problem is: where are you going to put javascripts to integrate
> with CodeMirror? I just have no idea on how to do it elegantly.
> Right now, I would create a TextAreaField and then add the required
> script to integrate CodeMirror in the template. Simple & efficient.
>
>


-- 
TROUVERIE Joachim
Ingénieur développement
*MEDIWARE* <http://www.mediware.fr/>
*High Tech Buro, Bat C, rue Garance,*
* 31670 LABEGE Cedex*