Exemplo n.º 1
0
    def create(self):
        """Trigger the creation of a ZIP file containing the site."""
        temp_file = NamedTemporaryFile(prefix=f'static-{self.event.id}-', suffix='.zip', dir=config.TEMP_DIR,
                                       delete=False)
        self._zip_file = ZipFile(temp_file.name, 'w', allowZip64=True)

        with collect_static_files() as used_assets:
            # create the home page html
            html = self._create_home()

            # Mathjax plugins can only be known in runtime
            self._copy_folder(os.path.join(self._content_dir, 'static', 'dist', 'js', 'mathjax'),
                              os.path.join(self._static_dir, 'dist', 'js', 'mathjax'))

            # Materials and additional pages
            self._copy_all_material()
            self._create_other_pages()

            # Create index.html file (main page for the event)
            index_path = os.path.join(self._content_dir, 'index.html')
            self._zip_file.writestr(index_path, html)

            self._write_generated_js()

        # Copy static assets to ZIP file
        self._copy_static_files(used_assets)
        self._copy_plugin_files(used_assets)
        if config.CUSTOMIZATION_DIR:
            self._copy_customization_files(used_assets)

        chmod_umask(temp_file.name)
        self._zip_file.close()
        return temp_file.name
Exemplo n.º 2
0
    def create(self):
        """Trigger the creation of a ZIP file containing the site."""
        temp_file = NamedTemporaryFile(suffix='indico.tmp', dir=config.TEMP_DIR)
        self._zip_file = ZipFile(temp_file.name, 'w', allowZip64=True)

        with collect_static_files() as used_assets:
            # create the home page html
            html = self._create_home().encode('utf-8')

            # Mathjax plugins can only be known in runtime
            self._copy_folder(os.path.join(self._content_dir, 'static', 'dist', 'js', 'mathjax'),
                              os.path.join(self._static_dir, 'dist', 'js', 'mathjax'))

            # Materials and additional pages
            self._copy_all_material()
            self._create_other_pages()

            # Create index.html file (main page for the event)
            index_path = os.path.join(self._content_dir, 'index.html')
            self._zip_file.writestr(index_path, html)

            self._write_generated_js()

        # Copy static assets to ZIP file
        self._copy_static_files(used_assets)
        self._copy_plugin_files(used_assets)
        if config.CUSTOMIZATION_DIR:
            self._copy_customization_files(used_assets)

        temp_file.delete = False
        chmod_umask(temp_file.name)
        self._zip_file.close()
        return temp_file.name