Generate the front page, aka index.html.
420952
def generate_index(self, num_posts=5):
		
		posts = self.get_posts(num=num_posts)
		self.generate_page('index', template='index.html.jinja', posts=posts)
716546
function start_html() {
        global $OUTPUT;

        // Render button to allow user to reset table preferences.
        echo $this->render_reset_button();

        // Do we need to print initial bars?
        $this->print_initials_bar();

        // Paging bar
        if ($this->use_pages) {
            $pagingbar = new paging_bar($this->totalrows, $this->currpage, $this->pagesize, $this->baseurl);
            $pagingbar->pagevar = $this->request[TABLE_VAR_PAGE];
            echo $OUTPUT->render($pagingbar);
        }

        if (in_array(TABLE_P_TOP, $this->showdownloadbuttonsat)) {
            echo $this->download_buttons();
        }

        $this->wrap_html_start();
        // Start of main data table

        echo html_writer::start_tag('div', array('class' => 'no-overflow'));
        echo html_writer::start_tag('table', $this->attributes);

    }
1185689
private function generateIndexView($dir)
    {
        $this->renderFile('views/index.html.twig', $dir.'/index.html.twig', array(
            'dir' => $this->skeletonDir,
            'document' => $this->document,
            'fields' => $this->metadata->fieldMappings,
            'actions' => $this->actions,
            'record_actions' => $this->getRecordActions(),
            'route_prefix' => $this->routePrefix,
            'route_name_prefix' => $this->routeNamePrefix,
        ));
    }
690609
function generateHTML(fileName) {
  return new Promise( resolve => {
    const location = fileName === 'index.html' ? '/' : `/${fileName}`;
    match({routes, location}, (error, redirectLocation, renderProps) => {
      let html = ReactDOMServer.renderToString(
        <RouterContext {...renderProps} />
      );
      html = '<!doctype html>' + html;
      let write = fsp.writeFile(path.join(docsBuilt, fileName), html);
      resolve(write);
    });
  });
}
1355210
public function generateSite()
    {

        $template = new TemplateImpl($this->backendContainer);
        $pageStrategy = $this->backendContainer->getCurrentPageStrategyInstance();


        $cacheControl = $this->backendContainer->getCacheControlInstance();
        if ($this->config->isDebugMode()) {
            $cacheControl->disableCache();
            $template->setTwigDebug(true);
        }


        $currentPage = $pageStrategy->getCurrentPage();
        $template->setTemplateFromConfig($currentPage->getTemplate(), "_main");

        $ajaxServer = $this->backendContainer->getAJAXServerInstance();
        $id = null;
        if (($id = $this->GETValueOfIndexIfSetElseDefault('ajax')) !== null) {
            $template->onlyInitialize();
            $ajaxServer->registerHandlersFromConfig();
        }

        //Decide output mode
        if ($id !== null) {
            echo json_encode($ajaxServer->handleFromFunctionString($id, $this->GETValueOfIndexIfSetElseDefault('token')), $this->config->isDebugMode()?JSON_PRETTY_PRINT:0);

        } else if (!$cacheControl->setUpCache()) {
            echo $template->render();
        }

    }
17238
def index
      respond_to do |format|
        format.html {
          @first_page = (params[:page] and params[:page].to_i > 0) ? false : true
          if params[:tag]
            @articles = Lines::Article.published.tagged_with(params[:tag]).page(params[:page].to_i)
          else
            @articles = Lines::Article.published.page(params[:page].to_i).padding(1)
          end
          
          if @articles.first_page?
            if @first_article = Article.published.first
              @first_article.teaser = nil unless @first_article.teaser.present?
            end
          end
          
          set_meta_tags title: SITE_TITLE,
                        description: CONFIG[:meta_description],
                        keywords: KEYWORDS,
                        open_graph: { title: SITE_TITLE,
                                        type: 'website',
                                        url: articles_url,
                                        site_name: SITE_TITLE,
                                        image: CONFIG[:og_logo]
                                      }

        }
        format.atom{
          @articles = Lines::Article.published
        }
      end
    end
576027
public function front()
    {
        $html = '';

        // Looping on plugins found inside the dragdrop zone to render them through their plugins
        // and get the HTML resulting in everything

        $plugins     = array();
        $containerId = null;
        foreach ($this->pluginFrontConfig['plugins'] as $plugin)
        {

            $tmpHtml = null;
            $datas = array(
                'action' => 'getPlugin',
                'module' => $plugin['pluginModule'],
                'pluginName' => $plugin['pluginName'],
                'pluginId' => $plugin['pluginId'],
                'pageId' => $this->pluginFrontConfig['pageId'],
                'fromDragDropZone' => true,
            );

            try
            {
                $forwardPlugin = $this->getController()->forward();

                $jsonResults = $forwardPlugin->dispatch('MelisFront\\Controller\\MelisPluginRenderer', $datas);


                if (!empty($jsonResults))
                {
                    $variables = $jsonResults->getVariables();
                    $containerId = isset($variables['datas']['dom']['pluginContainerId']) ?
                        $variables['datas']['dom']['pluginContainerId'] : count($plugins);

                    if (!empty($variables['success'])) {
                        //$html .= $variables['datas']['html'];
                        $tmpHtml = $variables['datas']['html'];
                    }

                    else  {
                        // problem with the plugins, we show the error only BO side
                        if ($this->renderMode == 'melis') {
                            //$html .= $variables['errors'] . ' : ' . $plugin['pluginModule'] . ' / ' . $plugin['pluginName'];
                            $tmpHtml = $variables['errors'] . ' : ' . $plugin['pluginModule'] . ' / ' . $plugin['pluginName'];
                        }
                    }

                }
            }
            catch (\Exception $e)
            {
                return array('pluginId' => $this->pluginFrontConfig['id']);

            }

            $plugins[$containerId][] = $tmpHtml;

        }


        // add container to dragdropzone

        $newHtml = !$this->isInBackOffice() ? '<div class="clearfix">' : '';
        foreach($plugins as $containerId => $contents) {
            foreach($contents as $idx => $content) {
                $newHtml .= "\t" . $content;
            }
        }

        $newHtml .= !$this->isInBackOffice() ? '</div>' : '';

        // Create an array with the variables that will be available in the view
        $viewVariables = array(
            'pluginId' => $this->pluginFrontConfig['id'],
            'pluginsHtml' => $newHtml,
        );

        // return the variable array and let the view be created
        return $viewVariables;
    }
1048693
def index_to_widget(self, idx):
        """"""
        nchild = self.widget.get_nth_page(idx)
        return self._native_to_child(nchild)
1262611
function generate(template, index) {

  var data,
      parser = parsers.getParser(template);

  if(typeof parser === 'function') {
    data = parser.call(this, template, index);
  } else {
    data = template;
  }
  return data;
}
702662
def __create_template_vars_index(self):
        """"""
        template_vars = {}
        template_vars["index"] = True
        template_vars["name"] = self.name
        template_vars["title"] = self.title
        template_vars["main_display"] = self.display
        template_vars["display_message"] = self.display_message
        
        template_vars["home_page_name"] = self.HomeName
        template_vars["current_section"] = "Home"
        
        template_vars["index_address"] = "index.html"
        template_vars["address_prefix"] = "./site"
        template_vars["nav_bar_right_side"] = self.nav_bar_right_side
        # Get the number of rows and how elements are organised
        template_vars["layout"] = self.__get_layout_of_the_current_page(self.HomeName, "Home")
        template_vars["headings"] = self.__get_headings_of_the_current_page(self.HomeName, "Home")
        
        
        # Plots, comments and table :
        template_vars["plots"] = self.__get_plots_of_the_current_page(self.HomeName, "Home")
        template_vars["comments_below"] = self.__get_below_comment_of_the_current_page(self.HomeName, "Home")
        template_vars["comments_above"] = self.__get_above_comment_of_the_current_page(self.HomeName, "Home")
        template_vars["tables"] = self.__get_table_of_the_current_page(self.HomeName, "Home")

        # Sections
        template_vars["sections"], template_vars["pages"], template_vars["pages_len"] = self.__create_lists_for_nav_bar()

        # footer
        template_vars["footer"] = self.footer

        #Css and JS
        template_vars["bootstrap_min_css"] = "./site/static/css/bootstrap.min.css"
        template_vars["jumbotron_css"] = "./site/static/css/jumbotron.css"
        template_vars["bootstrap_js"] = "./site/static/js/bootstrap.min.js"
        
        return template_vars
264978
private function render()
    {
        $str = $this->args['container_start'];

        if ($this->args['show_parent'] && $this->parent_page_id !== false) {
            $str .= $this->get_parent_link_html();
        }

        foreach ($this->pages as $page) {
            $str .= $this->get_link_html($page);
        }

        $str .= $this->args['container_end'];
        echo $str;
    }
764801
public function front()
    {
        // Get the parameters and config from $this->pluginFrontConfig (default > hardcoded > get > post)
        $data = $this->getFormData();

        // Plugin properties
        $pageId = empty($data['pageId']) ? null : $data['pageId'];
        $moduleName = empty($data['siteModuleName']) ? getenv('MELIS_MODULE') : $data['siteModuleName'];
        $keyword = empty($data['keyword']) ? null : $data['keyword'];

        // Pagination
        $current = empty($data['current']) ? 1 : $data['current'];
        $nbPerPage = empty($data['nbPerPage']) ? 10 : $data['nbPerPage'];
        $nbPageBeforeAfter = empty($data['nbPageBeforeAfter']) ? 0 : $data['nbPageBeforeAfter'];

        $moduleDirWritable = true;
        $indexUrl = '';
        $isIndex = false;
        $siteDirExist = true;

        $moduleDirectory = '';
        $searchModulePath = self::SEARCH_PATH_MELIS_SITES;
        if (!is_null($moduleName)) {
            if (is_dir($_SERVER['DOCUMENT_ROOT'] . self::MELIS_SITES . $moduleName)) {
                /** Module is located inside MelisSites folder */
                $moduleDirectory = $_SERVER['DOCUMENT_ROOT'] . self::MELIS_SITES . $moduleName;
            } elseif (is_dir($_SERVER['DOCUMENT_ROOT'] . self::VENDOR . $moduleName)) {
                /** Module is located inside Vendor folder */
                $moduleDirectory = $_SERVER['DOCUMENT_ROOT'] . self::VENDOR . $moduleName;
                $searchModulePath = self::SEARCH_PATH_VENDOR;
            } else {
                $siteDirExist = false;
            }

            if ($siteDirExist === true) {
                if (file_exists($moduleDirectory . '/luceneIndex/indexes')) {
                    $isIndex = true;
                    $indexUrl = '';
                } else {
                    if (is_writable($moduleDirectory . '/luceneIndex/')) {
                        if (is_null($pageId)) {
                            /**
                             * Getting the current page id
                             */
                            $renderMode = $this->getController()->params()->fromRoute('renderMode');

                            if ($renderMode == 'front') {
                                $pageId = $this->getController()->params()->fromRoute('idpage');
                            } else {
                                $pageId = $data['pageId'];
                            }
                        }

                        /**
                         * Indexing Site will use the main page of the Site
                         */
                        $pageTreeSrv = $this->getServiceLocator()->get('MelisEngineTree');
                        $pageSite = $pageTreeSrv->getSiteByPageId($pageId);
                        $mainPageId = empty($pageSite->site_main_page_id) ? 1 : $pageSite->site_main_page_id;

                        // Get the current server protocol
                        $protocol = stripos($_SERVER['SERVER_PROTOCOL'], 'https') === true ? 'https://' : 'http://';

                        $indexUrl = $protocol . $_SERVER['SERVER_NAME'] . '/melissearchindex/module/' . $moduleName . '/pageid/' . $mainPageId . '/exclude-pageid/0';
                    } else {
                        $moduleDirWritable = false;
                    }
                }
            }
        }

        $searchresults = [];
        if ($isIndex && $keyword) {
            /** @var \MelisEngine\Service\MelisSearchService $searchSvc */
            $searchSvc = $this->getServiceLocator()->get('MelisSearch');
            $searchresults = $searchSvc->search($keyword, $moduleName, true, $searchModulePath);
            if (!empty($searchresults)) {
                $searchresults = str_replace('&', '&amp;', $searchresults);

                $searchresults = (Array)simplexml_load_string($searchresults);
                $searchresults = (!empty($searchresults['result'])) ? $searchresults['result'] : [];

                // Checking if the Search array result is multidimensional array or single array
                if (is_object($searchresults)) {
                    // Making the search result to be multidimensional array
                    $temp[] = $searchresults;
                    $searchresults = $temp;
                }
            }
        }

        $paginator = new Paginator(new ArrayAdapter($searchresults));
        $paginator->setCurrentPageNumber($current)
            ->setItemCountPerPage($nbPerPage)
            ->setPageRange(($nbPageBeforeAfter * 2) + 1);

        // Create an array with the variables that will be available in the view
        $viewVariables = [
            'pluginId' => $this->pluginFrontConfig['id'],
            'moduleName' => $moduleName,
            'indexerOk' => $isIndex,
            'indexerURL' => $indexUrl,
            'moduleDirWritable' => $moduleDirWritable,
            'searchresults' => $paginator,
            'nbPageBeforeAfter' => $nbPageBeforeAfter,
            'siteDirExist' => $siteDirExist,
            'searchKey' => $keyword,
        ];

        // return the variable array and let the view be created
        return $viewVariables;
    }
1364220
public function frontpage() {
        global $CFG, $SITE;

        $output = '';

        if (isloggedin() and !isguestuser() and isset($CFG->frontpageloggedin)) {
            $frontpagelayout = $CFG->frontpageloggedin;
        } else {
            $frontpagelayout = $CFG->frontpage;
        }

        foreach (explode(',', $frontpagelayout) as $v) {
            switch ($v) {
                // Display the main part of the front page.
                case FRONTPAGENEWS:
                    if ($SITE->newsitems) {
                        // Print forums only when needed.
                        require_once($CFG->dirroot .'/mod/forum/lib.php');
                        if (($newsforum = forum_get_course_forum($SITE->id, 'news')) &&
                                ($forumcontents = $this->frontpage_news($newsforum))) {
                            $newsforumcm = get_fast_modinfo($SITE)->instances['forum'][$newsforum->id];
                            $output .= $this->frontpage_part('skipsitenews', 'site-news-forum',
                                $newsforumcm->get_formatted_name(), $forumcontents);
                        }
                    }
                    break;

                case FRONTPAGEENROLLEDCOURSELIST:
                    $mycourseshtml = $this->frontpage_my_courses();
                    if (!empty($mycourseshtml)) {
                        $output .= $this->frontpage_part('skipmycourses', 'frontpage-course-list',
                            get_string('mycourses'), $mycourseshtml);
                    }
                    break;

                case FRONTPAGEALLCOURSELIST:
                    $availablecourseshtml = $this->frontpage_available_courses();
                    $output .= $this->frontpage_part('skipavailablecourses', 'frontpage-available-course-list',
                        get_string('availablecourses'), $availablecourseshtml);
                    break;

                case FRONTPAGECATEGORYNAMES:
                    $output .= $this->frontpage_part('skipcategories', 'frontpage-category-names',
                        get_string('categories'), $this->frontpage_categories_list());
                    break;

                case FRONTPAGECATEGORYCOMBO:
                    $output .= $this->frontpage_part('skipcourses', 'frontpage-category-combo',
                        get_string('courses'), $this->frontpage_combo_list());
                    break;

                case FRONTPAGECOURSESEARCH:
                    $output .= $this->box($this->course_search_form('', 'short'), 'mdl-align');
                    break;

            }
            $output .= '<br />';
        }

        return $output;
    }
977
protected function generateIndex() {

		/**
			*  Handle missing index.html. Solves https://github.com/drupal-pattern-lab/patternlab-php-core/issues/14
			*  Could also be used to re-add missing styleguidekit assets with a few edits?
			*
			*  1. @TODO: Figure out a better way to future-proof path resolution for styleguidekit `dist` folder
			*  2. Recusirively copy files from styleguidekit to publicDir via https://stackoverflow.com/a/7775949
			*  3. Make sure we only try to create new directories if they don't already exist
			*  4. Only copy files if they are missing (vs changed, etc)
			*/
		if (!file_exists(Config::getOption("publicDir")."/index.html")) {
			$index = Console::getHumanReadablePath(Config::getOption("publicDir")).DIRECTORY_SEPARATOR."index.html";
			Console::writeWarning($index . " is missing. No biggie. Grabbing a fresh copy from your StyleguideKit...");

			$baseDir = Config::getOption("baseDir") . '/vendor';
			$finder = new Finder();

			// Locate the current theme's styleguidekit assets via the patternlab-styleguidekit `type` in composer.json
			$finder->files()->name("composer.json")->in($baseDir)->contains('patternlab-styleguidekit')->sortByName();

			foreach ($finder as $file) {
				$src = dirname($file->getRealPath()) . DIRECTORY_SEPARATOR . 'dist'; /* [1] */
				$dest= Config::getOption("publicDir");

				if (is_dir($src)){

					if(!is_dir($dest)) {
						mkdir($dest, 0755);
	        }

	        foreach ( /* [2] */
						$iterator = new \RecursiveIteratorIterator(
							new \RecursiveDirectoryIterator($src, \RecursiveDirectoryIterator::SKIP_DOTS), \RecursiveIteratorIterator::SELF_FIRST) as $item
					) {
						if ($item->isDir()) {
							if(!is_dir($dest . DIRECTORY_SEPARATOR . $iterator->getSubPathName())) { /* [3] */
								mkdir($dest . DIRECTORY_SEPARATOR . $iterator->getSubPathName());
							}
						} else {
							if(!file_exists($dest . DIRECTORY_SEPARATOR . $iterator->getSubPathName())) { /* [4] */
								copy($item, $dest . DIRECTORY_SEPARATOR . $iterator->getSubPathName());
							}
						}
					}
				}
			}
		}

		// set-up the dispatcher
		$dispatcherInstance = Dispatcher::getInstance();

		// note the start of the operation
		$dispatcherInstance->dispatch("builder.generateIndexStart");

		// default var
		$dataDir = Config::getOption("publicDir")."/styleguide/data";

		// double-check that the data directory exists
		if (!is_dir($dataDir)) {
			FileUtil::makeDir($dataDir);
		}

		$output = "";

		// load and write out the config options
		$config                         = array();
		$exposedOptions                 = Config::getOption("exposedOptions");
		foreach ($exposedOptions as $exposedOption) {
			$config[$exposedOption]     = Config::getOption($exposedOption);
		}
		$output     .= "var config = ".json_encode($config).";\n";

		// load the ish Controls
		$ishControls     = array();
		$controlsToHide  = array();
		$ishControlsHide = Config::getOption("ishControlsHide");
		if ($ishControlsHide) {
			foreach ($ishControlsHide as $controlToHide) {
				$controlsToHide[$controlToHide] = "true";
			}
		}
		$ishControls["ishControlsHide"] = $controlsToHide;
		$output      .= "var ishControls = ".json_encode($ishControls).";\n";

		// load and write out the items for the navigation
		$niExporter   = new NavItemsExporter();
		$navItems     = $niExporter->run();
		$output      .= "var navItems = ".json_encode($navItems).";\n";

		// load and write out the items for the pattern paths
		$patternPaths = array();
		$ppdExporter  = new PatternPathDestsExporter();
		$patternPaths = $ppdExporter->run();
		$output      .= "var patternPaths = ".json_encode($patternPaths).";\n";

		// load and write out the items for the view all paths
		$viewAllPaths = array();
		$vapExporter  = new ViewAllPathsExporter();
		$viewAllPaths = $vapExporter->run($navItems);
		$output      .= "var viewAllPaths = ".json_encode($viewAllPaths).";\n";

		// gather plugin package information
		$packagesInfo = array();
		$componentDir = Config::getOption("componentDir");
		if (!is_dir($componentDir)) {
			mkdir($componentDir);
		}
		$componentPackagesDir = $componentDir."/packages";
		if (!is_dir($componentDir."/packages")) {
			mkdir($componentDir."/packages");
		}
		$finder = new Finder();
		$finder->files()->name("*.json")->in($componentPackagesDir);
		$finder->sortByName();
		foreach ($finder as $file) {
			$filename = $file->getFilename();
			if ($filename[0] != "_") {
				$javascriptPaths = array();
				$packageInfo = json_decode(file_get_contents($file->getPathname()),true);
				foreach ($packageInfo["templates"] as $templateKey => $templatePath) {
					$templatePathFull = $componentDir."/".$packageInfo["name"]."/".$templatePath;
					$packageInfo["templates"][$templateKey] = (file_exists($templatePathFull)) ? file_get_contents($templatePathFull) : "";
				}
				foreach ($packageInfo["javascripts"] as $key => $javascriptPath) {
					$javascriptPaths[] = "patternlab-components/".$packageInfo["name"]."/".$javascriptPath;
				}
				$packageInfo["javascripts"] = $javascriptPaths;
				$packagesInfo[] = $packageInfo;
			}
		}
		$output .= "var plugins = ".json_encode($packagesInfo).";";

		// write out the data
		file_put_contents($dataDir."/patternlab-data.js",$output);
		// Structuring all the same data that went into `patternlab-data.js` and putting it into `patternlab-data.json` too
		$allPlData = array(
			'config' => $config,
			'ishControls' => $ishControls,
			'navItems' => $navItems,
			'patternPaths' => $patternPaths,
			'viewAllPaths' => $viewAllPaths,
			'plugins' => $packagesInfo,
		);
		file_put_contents($dataDir."/patternlab-data.json", json_encode($allPlData));

		// note the end of the operation
		$dispatcherInstance->dispatch("builder.generateIndexEnd");

	}
155312
function Generate()
    {
        if ($this->cacher->MustUseCache())
        {
            $this->xml = $this->cacher->GetFromCache();
            return;
        }
        $this->AddAllPages();
        $this->xml = $this->sitemap->SaveXml();
        if ($this->cacher->MustStoreToCache())
        {
            $this->cacher->StoreToCache($this->xml);
        }
    }
686656
def index(request, page):
    """"""
    days = []
    days_found = set()
    query = Entry.query.order_by(Entry.pub_date.desc())
    pagination = Pagination(query, PER_PAGE, page, "index")
    for entry in pagination.entries:
        day = date(*entry.pub_date.timetuple()[:3])
        if day not in days_found:
            days_found.add(day)
            days.append({"date": day, "entries": []})
        days[-1]["entries"].append(entry)
    return render_template("index.html", days=days, pagination=pagination)
727368
def main():
    """"""
    data = Common.open_file(F_INFO)
    config = Common.open_file(F_CONFIG)
    file_full_path = ""

    env = load_jinja2_env(config['p_template'])

    for index, page in data.iteritems():
        logging.info('Creating ' + index + ' page:')

        template = env.get_template(page['f_template'] + \
            config['f_template_ext'])

        for lang, content in page['content'].items():
            if lang == "NaL":
                if page['f_directory'] != '':
                    Common.make_dir(config['p_build'] + page['f_directory'])

                file_full_path = config['p_build'] + page['f_directory'] + \
                    page['f_name'] +page['f_endtype']
            else:
                if page['f_directory'] != '':
                    Common.make_dir(config['p_build'] + lang + '/' + \
                        page['f_directory'])

                file_full_path = config['p_build'] + lang + '/' + \
                    page['f_directory'] + page['f_name'] +page['f_endtype']

            with open(file_full_path, 'w') as target_file:
                target_file.write(template.render(content))

        logging.info('Page ' + index + ' created.')