scaffold & helpers

68 views
Skip to first unread message

Erich Meyer

unread,
Mar 3, 2021, 2:20:14 AM3/3/21
to py4web
Hi, what i wish for:
 
_scaffold should include side_board_left and sideboard_right.
MARKMIN should be among the helpers

I would like to be able to import my elaborations, which I have written under Web2Py, into Py4Web. I have already implemented the table of contents in the nested sets technology according to Py4Web.

I had extended MARKMIN for myself so that I could insert image and audio files; I would also like to have iframes

Erich

Kevin Keller

unread,
Mar 3, 2021, 2:51:08 AM3/3/21
to Erich Meyer, py4web
http://www.web2py.com/init/static/markmin.html


Extracting markmin from web2py and putting it into the py4web utils folder would make it available for you.

Why don't you share your improved markmin version and we use this for py4web?

Happy to create the pr for you and use it markmin in an example app.

Sideboard is probaly some css that you like or menu?
Maybe you can share a Screenshot. 

Finally could you share what you have done for your table of contents so others can learn too how to write their eloborarions with py4web? 

Thanks! 




--
You received this message because you are subscribed to the Google Groups "py4web" group.
To unsubscribe from this group and stop receiving emails from it, send an email to py4web+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/py4web/cf64f675-654e-455e-a83c-b646aa0dc20dn%40googlegroups.com.

Erich Meyer

unread,
Mar 3, 2021, 3:34:12 AM3/3/21
to py4web
my improved markmin version
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
<script type="text/javascript"
  src='https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-MML-AM_CHTML' async>
</script>
   
<style type="text/css">
   code {background-color: #ffffff; border: 0px; color: #ad0d0d; }
    hr {border-width: 2px 0; line-height: 8px}
   .fehler {color: #00bb00;}
</style>  

{{def markmin(text):
      return(MARKMIN(text,
                     extra=dict(br=lambda x: BR(),
                                hr=lambda x: HR(),
                                img=lambda x: make_img(x),
                                wav=lambda x: make_wav(x),
                                html=lambda x: make_html(x),

                                code_cpp=lambda text: CODE(text,language='cpp').xml(),
                                code_python=lambda text: CODE(text,language='python').xml(),
                                code_html=lambda text: CODE(text,language='html').xml(),
                                code_ly=lambda text: CODE(text,language='ly').xml())))
   pass}}
   
{{def make_html(text):
     out = XML(text, sanitize=False, permitted_tags=[pre,b,span],allowed_attributes={'pre':['style'],'span':['style']})
  return(out)
pass}}

{{import re}}
{{regex_picture=re.compile(ur'\s*(?P<title>[a-zäöüßA-ZÄÖÜ_0-9]+(\.[a-zA-Z0-9]+)*)\s*(?P<width>[0-9]+)\s*', re.UNICODE)}}
{{regex_text=re.compile(ur'\s*(?P<title>[a-zäöüßA-ZÄÖÜ_0-9]+(\.[a-zA-Z0-9]+)*)\s*', re.UNICODE)}}

{{def make_img(text):
    text=regex_picture.match(text)
    
    try:
        image = db(db.image.title==text.group('title')).select().first()
        out = IMG( _src=URL(c='default', f='download', args=image.image_data), _width=text.group('width'))
    except:
        try:
            out = DIV('Bild '+text.group('title')+' steht nicht zur Verfügung', _class='fehler')    
        except:  
            out = DIV('width des Bildes scheint zu fehlen', _class='fehler')  
        pass
    pass    
    return(out)           
pass}}

{{def make_wav(text):
    text=regex_text.match(text)
    try:
      music = db(db.music.title==text.group('title')).select().first()   
      src = URL(c='default', f='download', args=music.music_data)
      out = '<audio src="'+src+'" controls="controls" type="audio/wav" ></audio>'
    except:
        out = DIV('Audio-Datei '+text.group('title')+' steht nicht zur Verfügung', _class='fehler')
    pass
    return(out)           
pass}}
--------------------------------------------------------------------------------------------------------------------------------------------

Unfortunately, I only have German pages as a demo:
for example:

Erich Meyer

unread,
Mar 3, 2021, 3:54:15 AM3/3/21
to py4web
When I created a new application using  _scaffold, no py4web utils folder was created

Kevin Keller

unread,
Mar 3, 2021, 4:01:40 AM3/3/21
to Erich Meyer, py4web
That is ok, I speak German :). I am from Bremerhaven. 

I will create a PR to see if Massimo will merge your markmin into py4web. 

After the merge you will be able to import it like so:

import py4web.utils.markmin2html 

and use it just as you used it with py4web. 

So you would like an automatically generated table of contents?

image.png

or this black menu: 

image.png



image.png
image.png

Kevin Keller

unread,
Mar 3, 2021, 4:15:08 AM3/3/21
to Erich Meyer, py4web
Erich, which file is this that you improved? 

markmin2html.py ?

I just created a pull with the current vanilla version of markmin for py4web, but if you want me to include your improved version I need to know which file you have changed here :). 

Thanks!



Kevin Keller

unread,
Mar 3, 2021, 4:17:00 AM3/3/21
to Erich Meyer, py4web
This looks more like you have used markmin as is and enriched your html template with custom logic. 

But we can use it as an markmin example in py4web. 
cloudHQPowered by
cloudHQ

Erich Meyer

unread,
Mar 3, 2021, 5:02:41 AM3/3/21
to py4web
Hallo Kevin, ich wohne bei Kiel

Um es einfach zu machen, ich würde Dir mein Passwort anvertrauen, damit Du meine Seite bei python.anywhere.com inspizieren kannst.
Ich könnte Dir das Passwort über posteo.de zusenden; posteo.de macht ende zu ende verschlüsselung
Ich habe noch nie meinen eMail-Account bei gmail verwendet; kann ich Deinen gmail-account verwenden?

Gruß Erich
Reply all
Reply to author
Forward
0 new messages