Ejemplo n.º 1
0
    def create_panel(self, match):
        arguments = match.group('args')
        teacher_only_panels = self.guide.generator_settings['Output'][
            'Teacher Only Panels'].strip().split('\n')
        panel_type = parse_argument('type', arguments)
        if panel_type:
            # Check if panel allowed
            if not (self.guide.version != "teacher"
                    and panel_type in teacher_only_panels):
                title = systemfunctions.from_kebab_case(panel_type)
                summary_value = parse_argument('summary', arguments)
                summary = ': ' + summary_value.strip() if summary_value else ''
                expanded_value = parse_argument('expanded', arguments)
                expanded = ' active' if expanded_value == 'True' else ''
                content = markdown(match.group('content'),
                                   extras=MARKDOWN2_EXTRAS)

                heading = self.html_templates['panel_heading'].format(
                    title=title, summary=summary)
                html = self.html_templates['panel'].format(
                    panel_heading=heading,
                    content=content,
                    type_class='panel-' + panel_type,
                    expanded=expanded)
            # Panel should be ignored
            else:
                html = ''
        else:
            self.regex_functions['panel'].log("Panel type argument missing",
                                              self, match.group(0))
            html = ''
        return html
Ejemplo n.º 2
0
    def create_panel(self, match):
        arguments = match.group('args')
        teacher_only_panels = self.guide.generator_settings['Output']['Teacher Only Panels'].strip().split('\n')
        panel_type = parse_argument('type', arguments)
        if panel_type:
            # Check if panel allowed
            if not (self.guide.version != "teacher" and panel_type in teacher_only_panels):
                title = systemfunctions.from_kebab_case(panel_type)
                summary_value = parse_argument('summary', arguments)
                summary = ': ' + summary_value.strip() if summary_value else ''
                expanded_value = parse_argument('expanded', arguments)
                expanded = ' active' if expanded_value == 'True'  else ''
                content = markdown(match.group('content'), extras=MARKDOWN2_EXTRAS)

                heading = self.html_templates['panel_heading'].format(title=title,
                                                                      summary=summary)
                html = self.html_templates['panel'].format(panel_heading = heading,
                                                           content = content,
                                                           type_class = 'panel-' + panel_type,
                                                           expanded = expanded)
            # Panel should be ignored
            else:
                html = ''
        else:
            self.regex_functions['panel'].log("Panel type argument missing", self, match.group(0))
            html = ''
        return html
Ejemplo n.º 3
0
    def create_panel(self, match):
        arguments = match.group('args')
        teacher_only_panels = self.guide.generator_settings['Output']['Teacher Only Panels'].strip().split('\n')
        panel_type = parse_argument('type', arguments)
        if panel_type:
            # Check if panel allowed
            if not (self.guide.version != "teacher" and panel_type in teacher_only_panels):
                title = systemfunctions.from_kebab_case(panel_type)
                summary_value = parse_argument('summary', arguments)
                summary = ': ' + summary_value.strip() if summary_value else ''
                expanded_value = parse_argument('expanded', arguments)
                expanded = ' active' if expanded_value == 'True' else ''
                content = self.parse_markdown(match.group('content'))

                heading = self.html_templates['panel_heading'].format(title=title,
                                                                      summary=summary)
                html = self.html_templates['panel'].format(panel_heading = heading,
                                                           content = content,
                                                           type_class = 'panel-' + panel_type,
                                                           expanded = expanded)
            # Panel should be ignored
            else:
                html = ''
            # Check for tags within panel that could cause dead links within student version
            if panel_type in teacher_only_panels:
                content = match.group('content')
                for line in content.split('\n'):
                    if 'glossary-definition' in line:
                        self.regex_functions['panel'].log('This teacher only panel contains a glossary definition. The definition must be moved outside the teacher only section to function correctly.', self, match.group(0).split('\n')[0])
                    if 'glossary-link-back-reference' in line:
                        self.regex_functions['panel'].log('This teacher only panel contains a glossary link with a back reference. We currently don\'t support back references within teacher only panels, please remove the reference.', self, match.group(0).split('\n')[0])
        else:
            self.regex_functions['panel'].log("Panel type argument missing", self, match.group(0).split('\n')[0])
            html = ''
        return html
Ejemplo n.º 4
0
 def __init__(self, name, parent=None, guide=None):
     self.name = name
     self.parent = parent
     self.folders = []
     self.files = []
     self.folders_dict = {}
     self.files_dict = {}
     self.depth = (parent.depth + 1) if parent else -1
     self.path = os.path.join(self.parent.path, self.name) if self.parent else ''
     self.guide = self.parent.guide if parent else guide
     self.english_title = systemfunctions.from_kebab_case(self.name)
     if self.parent:
         self.title = self.guide.translations[self.name][self.guide.language_code]
     else:
         #Folder is root folder, name is not important
         self.title = self.english_title
Ejemplo n.º 5
0
 def __init__(self, name, parent=None, guide=None):
     self.name = name
     self.parent = parent
     self.folders = []
     self.files = []
     self.folders_dict = {}
     self.files_dict = {}
     self.depth = (parent.depth + 1) if parent else -1
     self.path = os.path.join(self.parent.path,
                              self.name) if self.parent else ''
     self.guide = self.parent.guide if parent else guide
     self.english_title = systemfunctions.from_kebab_case(self.name)
     if self.parent:
         self.title = self.guide.translations[self.name][
             self.guide.language_code]
     else:
         #Folder is root folder, name is not important
         self.title = self.english_title
Ejemplo n.º 6
0
    def create_panel(self, match):
        arguments = match.group('args')
        teacher_only_panels = self.guide.generator_settings['Output']['Teacher Only Panels'].strip().split('\n')
        panel_type = parse_argument('type', arguments)
        if panel_type:
            # Check if panel allowed
            if not (self.guide.version != "teacher" and panel_type in teacher_only_panels):
                title = parse_argument('title', arguments)
                if not title:
                    title = systemfunctions.from_kebab_case(panel_type)
                summary_value = parse_argument('summary', arguments)
                summary = ': ' + summary_value.strip() if summary_value else ''
                expanded_value = parse_argument('expanded', arguments)
                collapsible = False if expanded_value == 'Always' else True
                valid_expanded_values = ['True', 'Always']
                expanded = expanded_value in valid_expanded_values
                context = {
                    'type_class': panel_type,
                    'title': title,
                    'summary': summary,
                    'content': self.parse_markdown(match.group('content')),
                    'expanded': expanded,
                    'collapsible': collapsible
                }
                html = self.guide.html_generator.render_template('panel', context)
            # Panel should be ignored
            else:
                html = ''

            # Check for tags within panel that could cause dead links within student version
            if panel_type in teacher_only_panels:
                content = match.group('content')
                for line in content.split('\n'):
                    if 'glossary-definition' in line:
                        self.regex_functions['panel'].log('This teacher only panel contains a glossary definition. The definition must be moved outside the teacher only section to function correctly.', self, match.group(0).split('\n')[0])
                    if 'glossary-link-back-reference' in line:
                        self.regex_functions['panel'].log('This teacher only panel contains a glossary link with a back reference. We currently don\'t support back references within teacher only panels, please remove the reference.', self, match.group(0).split('\n')[0])
        else:
            self.regex_functions['panel'].log("Panel type argument missing", self, match.group(0).split('\n')[0])
            html = ''
        return html