Beispiel #1
0
 def set_html(self):
     '''
     Sets html code
     
     Inputs:
         -
         
     Output:
         None
     '''
     
     # --- Definitions
     nid = self.inputs.getvalue('note')
     
     H = self.html
     
     # --- Head
     H.style('note')
     H.jsfile('Core/JS/note.js')
     
      # Context menu
     H.style('ContextMenu')
     H.jsfile('Core/JS/jquery.contextMenu.min.js')
     H.jsfile('Core/JS/jquery.ui.position.min.js')
     
     # --- Structure
     H.table(0, id='structure')
     H.tr()
     menu_bar = H.td(id='menu_bar')
     main = H.td(id='main')
     
     # ---------------------------------------
     #   MENU
     # ---------------------------------------
     
     # Logo
     tree = DB('../Notes/{0}/Tree.db'.format(self.session.user['id']))
     res = tree.single('SELECT parent FROM Elements WHERE id=?', nid)
     
     H.a(menu_bar, '?spot=home&parent={0}'.format(res['parent']))
     H.img(0, 'Core/Style/Logo.svg', id='logo')
     
     # --- Menu
     menu = H.div(menu_bar, id='menu')
    
     H.div(menu, id='cont_page')
     self.icon('new_page_before', "new_page('before');", ('New page before', 'Nouvelle page avant'))
     self.icon('merge_previous', "merge('previous');",   ('Merge with previous page', 'Fusionnez avec\nla page précédente'))
     self.icon('merge_next', "merge('next');",           ('Merge with next page', 'Fusionnez avec\nla page suivante'))
     self.icon('new_page_after', "new_page('after');",   ('New page after', 'Nouvelle page après'))
     
     self.icon('delete_page', 'delete_page();',     ('Delete page', 'Supprimer la page'))
     
     H.div(menu, id='cont_spacer')
     self.icon('new_page_here', 'new_page();',   ('New page', 'Nouvelle page'))
     self.icon('merge', 'merge();',              ('Merge pages', 'Fusionner les pages'))
     
     # ---------------------------------------
     #   MAIN
     # ---------------------------------------
     
     tree = DB('../Notes/{0}/Tree.db'.format(self.session.user['id']))
     note = DB('../Notes/{0}/{1}/Note.db'.format(self.session.user['id'], nid))
     
     # --- Display ---------------------------
     
     # --- Navigation bar
     self.navbar(tree, main, nid)
     
     # --- Pages
     Pcont = H.div(main, id='Pages')
         
     for page in note.multi("SELECT * FROM Pages ORDER BY position"):    
     
         pcont = H.div(Pcont, cls='page_cont')
         pid = page['id']
     
         # --- Spacer before
         H.a(pcont, '#', id='spacer_b{0}'.format(pid), cls='spacer_before')
     
         # --- Page link
         H.a(pcont, '?spot=page&note={0}&page={1}'.format(nid, pid), id='page_{0}'.format(pid), cls='page')
         
         # --- Page name
         H.center(0)
         H.p(0, cls='page_name')
         if page['name']:
             H.text(0, page['name'])
         else:
             H.span(0, cls='nav_undef')
             H.text(0, 'Page {0}'.format(page['position']))
         
         # --- Minipage
         mini = H.div(-1, cls='minipage')
         
         for row in note.multi('SELECT * FROM Elements WHERE page=? ORDER BY position LIMIT 7', pid):
         
             # --- Highlight ?
             if row['highlight']:
                 H.div(mini, cls='highlight')
             else:
                 H.div(mini)
         
             # --- Element
             res = note.single('SELECT * FROM {0} WHERE id=?'.format(row['type']), row['id'])
         
             # HEADER
             if row['type'] in ('header'):            
                 H.p(0, cls='mini_h'+str(res['level']))
                 H.text(0, res['text'])
         
             # TEXT
             if row['type'] in ('text'):
                 H.p(0, cls='mini_p')
                 H.text(0, self.truncate(res['text'], limit=65))
         
             # EQUATION
             if row['type'] in ('equation'):
                 iname = '../Notes/{0}/{1}/Medias/{2}.svg'.format(self.session.user['id'], nid, row['id'])
                 if not isfile(iname):
                     iname = 'Core/Style/default.png'    
                 H.img(0, iname, cls='mini_equation')
                 
             # IMAGE / MOVIE
             if row['type'] in ('media'):
             
                 Mtype = res['type']
                 Mname = '../Notes/{0}/{1}/Medias/{2}.{3}'.format(self.session.user['id'], nid, row['id'], res['ext'])
                 if not isfile(Mname):
                     Mtype = 'image'
                     Mname = 'Core/Style/default.png'
                     
                 if Mtype in ('image'):
                     H.img(0, Mname)
                 if Mtype in ('video'):
                     H.video(0, Mname)
      
         # --- Spacer after
         H.a(pcont, '#', id='spacer_a{0}'.format(pid), cls='spacer_after')
     
     # ---------------------------------------
     #   PHANTOM BOX
     # ---------------------------------------
     
     H.div(H.body, id='phantom', onclick='close_phantom();')
     H.div(0, id='box')
Beispiel #2
0
    def set_html(self):
        '''
        Sets html code
        
        Inputs:
            -
            
        Output:
            None
        '''
        
        if self.inputs.getvalue('parent') is None or self.inputs.getvalue('parent')=='0':
            parent = 0
        else:
            parent = self.inputs.getvalue('parent')
        
        # --- Definitions
        H = self.html
        
        # --- Head
        H.style('home')
            
        # --- Structure
        H.table(0, id='structure')
        H.tr()
        menu = H.td(id='menu_bar')
        main = H.td(id='main')
        
        # ---------------------------------------
        #   MENU
        # ---------------------------------------
        
        # Menu containers
        H.ref = menu
        H.img(0, 'Core/Style/Logo.svg', id='logo')
        
        # --- Disconnection
        H.div(0, id='menu')
        
        H.a(0, '?spot=connection', id='disconnection')
        H.a(-1, '?', id='profile', cls='menu_item')
        H.text(0, ("My account", "Mon profil"))
        
        H.a(-1, '?', id='param', cls='menu_item')
        H.text(0, ("Settings", "Paramètres"))
                
        # ---------------------------------------
        #   MAIN
        # ---------------------------------------
        
        tree = DB('../Notes/{0}/Tree.db'.format(self.session.user['id']))
        
        # --- Display ---------------------------
        
        # --- Navigation bar
        self.navbar(tree, main, parent)
        
        # --- Groups and notes
        
        cont = H.div(main, id='Notes')
        
        res = tree.single("SELECT type FROM Elements WHERE id=?", parent)
        if res is None or res['type']=='group':
        
            # Groups
            for row in tree.multi("SELECT * FROM Elements WHERE parent=? AND type='group'", parent):
                H.a(cont, '?spot=home&parent={0}'.format(row['id']), cls='elm')
                H.center(0)
                H.img(0, 'Core/Style/Icons/folder.png')
                H.p(0)
                if row['name']:
                    H.text(0, row['name'])
                else:
                    H.span(0, cls='nav_undef')
                    H.text(0, 'Group {0}'.format(row['id']))
            
            # Notes
            for row in tree.multi("SELECT * FROM Elements WHERE parent=? AND type='note'", parent):
                H.a(cont, '?spot=note&note={0}'.format(row['id']), cls='elm')
                H.center(0)
                H.img(0, 'Core/Style/Icons/note.png')
                H.p(0)
                if row['name']:
                    H.text(0, row['name'])
                else:
                    H.span(0, cls='nav_undef')
                    H.text(0, 'Note {0}'.format(row['id']))
            
        elif res['type']=='note':

                row = tree.single("SELECT * FROM Elements WHERE id=?", parent)

                # row['name']

                for i in range(10):

                    H.a(cont, '?spot=page&note={0}&page=1'.format(row['id']), cls='page')
                    H.div(0, cls='minipage')
                    H.text(0, 'This is a test !')
                    
                    H.center(-1)
                    H.p(0)
                    H.text(0, 'Page {0}'.format(i))
Beispiel #3
0
 def set_html(self):
     '''
     Sets html code
     
     Inputs:
         -
         
     Output:
         None
     '''
     
     # --- Definitions
     pid = self.inputs.getvalue('page')
     nid = self.inputs.getvalue('note')
     
     H = self.html
     
     # --- Head
     H.style('page')
     H.jsfile('Core/JS/page.js')
     
     # Context menu
     H.style('ContextMenu')
     H.jsfile('Core/JS/jquery.contextMenu.min.js')
     H.jsfile('Core/JS/jquery.ui.position.min.js')
     
     # --- Structure
     
     H.table(0, id='structure')
     H.tr()
     menu_bar = H.td(id='menu_bar')
     main = H.td(id='main')
     
     # ---------------------------------------
     #   MENU
     # ---------------------------------------
     
     # Logo
     tree = DB('../Notes/{0}/Tree.db'.format(self.session.user['id']))
     res = tree.single('SELECT parent FROM Elements WHERE id=?', nid)
     
     H.a(menu_bar, '?spot=home&parent={0}'.format(res['parent']))
     H.img(0, 'Core/Style/Logo.svg', id='logo')
     
     # --- Menu
     menu = H.div(menu_bar, id='menu')
    
     H.div(menu, id='cont_links')
     self.icon('read', '',                       ('Switch to read mode', 'Passer en mode lecture'))
     self.icon('pdf', '',                        ('Export to pdf', 'Exporter en pdf'))
     self.icon('link', '',                       ('Link to this note (URL)', 'Lien vers cette note (URL)'))
     self.icon('share', '',                      ('Share this note', 'Partage de la note'))
    
     H.div(menu, id='cont_pages')
     self.icon('new_page', '',                   ('Create a new page', 'Créer une nouvelle page'))
     self.icon('merge_prev', '',                 ('Merge with previous page', 'Fusionnez avec\nla page précédente'))
    
     H.div(menu, id='cont_new_elm')
     self.icon('new_header', "insert_elm('header');",     ('Insert title', 'Insérer un titre'))
     self.icon('new_text', "insert_elm('text');",         ('Insert text paragraph', 'Insérer un paragraphe'))
     self.icon('new_equation', "insert_elm('equation');", ('Insert equation', 'Insérer une équation'))
     self.icon('new_code', '',                            ('Insert code', 'Insérer du code'))
     self.icon('new_timestamp', '',                       ('Insert timestamp', 'Insérer un repère temporel'))
     self.icon('new_image', "insert_elm('media');",       ('Insert image/movie', 'Insérer une image ou un film'))
     self.icon('new_drawing', '',                         ('Insert freehand drawing', 'Insérer un dessin à main levée'))
     
     H.div(menu, id='cont_elm')
     self.icon('elm_modify', 'modify();',        ('Modify this element', 'Modifier cet élément'))
     self.icon('elm_highlight', 'highlight();',  ('Highlight this element', 'Mettre en valeur'))
     self.icon('elm_comment', '',                ('Comment this element', 'Commenter cet élément'))
     self.icon('elm_delete', 'delete_elm();',    ('Delete this element', 'Supprimer cet élément'))
            
     #H.ref = menu
     #H.text(H.a('#', onclick='console.log(mov_state); return 0;'), 'Test')
     #H.text(H.div(id='node'), 'Test')
            
     # ---------------------------------------
     #   MAIN
     # ---------------------------------------
             
     tree = DB('../Notes/{0}/Tree.db'.format(self.session.user['id']))
     note = DB('../Notes/{0}/{1}/Note.db'.format(self.session.user['id'], nid))
     
     # --- Display ---------------------------
     
     # --- Navigation bar
     self.navbar(tree, main, nid, page=(note, nid, pid))
     
     # --- Fake element for the first spacer
     H.div(main, cls='elm_text', style='height:50px')
             
     for row in note.multi('SELECT * FROM Elements WHERE page=? ORDER BY position', pid):
         
         # --- Spacer
         H.div(main, cls='spacer', id='spacer_{0}'.format(row['id']))
         
         # --- Element
         elmid = 'elm_{0}'.format(row['id'])
         res = note.single('SELECT * FROM {0} WHERE id=?'.format(row['type']), row['id'])
         
         if row['highlight']:
             H.div(main, cls='elm elm_{0} highlight'.format(row['type']), id=elmid)
         else:
             H.div(main, cls='elm elm_{0}'.format(row['type']), id=elmid)
         
         # -----------------------------------
         #  HEADER
         # -----------------------------------
         
         if row['type'] in ('header'):
             H.p(0, id='{0}_text'.format(elmid), cls='elm_h'+str(res['level']))
             H.text(0, res['text'])
             
         # -----------------------------------
         #  TEXT
         # -----------------------------------
         
         if row['type'] in ('text'):
             H.p(0, id='{0}_text'.format(elmid))
             H.text(0, res['text'])
         
         # -----------------------------------
         #  EQUATION
         # -----------------------------------
         
         if row['type'] in ('equation'):
             ref = H.ref
             H.div(0, cls='eq_node')
             H.p(0, id='{0}_text'.format(elmid))
             H.text(0, res['text'])
             
             iname = '../Notes/{0}/{1}/Medias/{2}.svg'.format(self.session.user['id'], nid, row['id'])
             if isfile(iname):
                 w = None
                 ifile = open(iname, 'r')
                 for line in ifile:
                     m = re.search('width="([0-9]*)pt"', line)
                     if m is not None:
                         w = float(m.group(1))
                         break
             else:
                 iname = 'Core/Style/default.png'
                 
             if w is None:
                 H.img(-2, iname, id='{0}_img'.format(elmid))
             else:
                 H.img(-2, iname, id='{0}_img'.format(elmid), width='{0}px'.format(w*float(self.settings.get('equation_display_factor'))))
         
         # -----------------------------------
         #  IMAGE, MOVIE
         # -----------------------------------
         
         if row['type'] in ('media'):
             
             Mtype = res['type']
             Mname = '../Notes/{0}/{1}/Medias/{2}.{3}'.format(self.session.user['id'], nid, row['id'], res['ext'])
             if not isfile(Mname):
                 Mtype = 'image'
                 Mname = 'Core/Style/default.png'
                 
             if Mtype in ('image'):
                 H.img(0, Mname, id='{0}_media'.format(elmid))
             if Mtype in ('video'):
                 H.video(0, Mname, id='{0}_media'.format(elmid))
                 
             H.form(0, id='{0}_form'.format(elmid))
             H._hidden(0, 'note', nid)
             H._hidden(0, 'elm', str(row['id']))
             H._file(0, id='{0}_file'.format(elmid), name="file", cls='file')
             
     # --- Last spacer
     H.div(main, cls='spacer default_spacer', id='spacer_0')
         
     # --- Fake element for the last spacer
     H.div(main, cls='elm_text', style='height:50px')
     
     # ---------------------------------------
     #   UNSELECT BOX
     # ---------------------------------------
     
     H.div(main, id='unselect')
     
     # ---------------------------------------
     #   PHANTOM BOX
     # ---------------------------------------
     
     H.div(H.body, id='phantom', onclick='close_phantom();')
     H.div(0, id='box')