Make sure site home pages are loaded at the root of the site.
160758
public function contentcontrollerInit($controller)
    {

        // If we've accessed the homepage as /home/, then we should redirect to /.
        if ($controller->dataRecord && $controller->dataRecord instanceof SiteTree && MultisitesRootController::should_be_on_root($controller->dataRecord)
            && (!isset($controller->urlParams['Action']) || !$controller->urlParams['Action'] ) && !$_POST && !$_FILES && !$controller->redirectedTo()) {
            $getVars = $_GET;
            unset($getVars['url']);
            if ($getVars) $url     = "?".http_build_query($getVars);
            else $url     = "";
            $controller->redirect($url, 301);
            return;
        }
    }
1350527
def render_homepage(config, env):
    """"""
    template = env.get_template('homepage.jinja')
    rendered_page = template.render(
        config=config)
    return rendered_page
902350
private function sailHome()
    {
        $routes = Registry::ahoy()->get('routes');
        $home_page = $routes['/'];
        $this->controller = $home_page['controller'];
        $this->action = $home_page['action'];
        $this->params = $home_page['params'];
    }
936714
def check_homepage(package_info, *args):
    
    reason = "Home page missing"
    result = False

    if package_info.get('home_page') not in BAD_VALUES:
        result = True

    return result, reason, HAS_HOMEPAGE
297903
def is_root(self):
        """"""
        sub_prefix = self.reddit_session.config.by_object[Submission]
        return self.parent_id.startswith(sub_prefix)
471647
def create_site(self, site, states=None):
        """"""
        if site not in self.sites:
            self.sites.append(site)
        if states is not None:
            self.site_states.setdefault(site, [])
            try:
                states = list(states)
            except TypeError:
                return
            self.add_site_states(site, states)
659089
function (index, callback) {
            $.when(pages[index] && pages[index].load())
                .always(callback);
        }
1152518
def reload_site(self):
        """"""
        rev = int(self.db.get('site:rev'))
        if rev != self.revision and self.db.exists('site:rev'):
            timeline = self.db.lrange('site:timeline', 0, -1)
            self._timeline = []
            for data in timeline:
                data = json.loads(data.decode('utf-8'))
                self._timeline.append(Post(data[0], self.config, data[1],
                                           data[2], data[3], self.messages,
                                           self._site.compilers[data[4]]))

            self._read_indexlist('posts')
            self._read_indexlist('all_posts')
            self._read_indexlist('pages')

            self.revision = rev
            self.logger.info("Site updated to revision {0}.".format(rev))
        elif rev == self.revision and self.db.exists('site:rev'):
            pass
        else:
            self.logger.warn("Site needs rescanning.")
282659
public void addSite(String site) {
		if (siteModel.getIndexOf(site) < 0) {
			siteModel.addElement(site);
			if (currentSite == null) {
				// First site added, automatically select it
				siteModel.setSelectedItem(site);
			}
		}
	}
132202
public static void reloadProperties() {
    synchronized (DEFAULT_PROPERTIES_LOCK) {
      // Step1: bootstrap the configuration. This is necessary because we need to resolve alluxio
      // .home (likely to be in system properties) to locate the conf dir to search for the site
      // property file.
      AlluxioProperties properties = new AlluxioProperties();
      InstancedConfiguration conf = new InstancedConfiguration(properties);
      properties.merge(System.getProperties(), Source.SYSTEM_PROPERTY);

      // Step2: Load site specific properties file if not in test mode. Note that we decide
      // whether in test mode by default properties and system properties (via getBoolean).
      if (conf.getBoolean(PropertyKey.TEST_MODE)) {
        conf.validate();
        sDefaultProperties = properties;
        return;
      }

      // we are not in test mode, load site properties
      String confPaths = conf.get(PropertyKey.SITE_CONF_DIR);
      String[] confPathList = confPaths.split(",");
      String sitePropertyFile = ConfigurationUtils
          .searchPropertiesFile(Constants.SITE_PROPERTIES, confPathList);
      Properties siteProps = null;
      if (sitePropertyFile != null) {
        siteProps = loadPropertiesFromFile(sitePropertyFile);
        sSourcePropertyFile = sitePropertyFile;
      } else {
        URL resource =
            ConfigurationUtils.class.getClassLoader().getResource(Constants.SITE_PROPERTIES);
        if (resource != null) {
          siteProps = loadPropertiesFromResource(resource);
          if (siteProps != null) {
            sSourcePropertyFile = resource.getPath();
          }
        }
      }
      properties.merge(siteProps, Source.siteProperty(sSourcePropertyFile));
      conf.validate();
      sDefaultProperties = properties;
    }
  }
305530
public function onAfterInit()
    {
        if ($this->owner instanceof DatabaseAdmin) {
            //
            // 2016-12-16 -	This is disabled in sitetree.yml to stop users placing
            //				pages above a Site. However, during dev/build we don't
            //				want pages validated so they can be placed top-level, and
            //				then be moved underneath Site during it's
            //				requireDefaultRecords() call.
            //
			SiteTree::config()->can_be_root = true;
            return;
        }

        if ($this->owner instanceof DevelopmentAdmin ||
            $this->owner instanceof DevBuildController ||
            $this->owner instanceof DatabaseAdmin) {
            return;
        }

        $site = Multisites::inst()->getCurrentSite();
        if (!$site) {
            return;
        }

        // are we on the frontend?
        if (!$this->owner instanceof \SilverStripe\Admin\LeftAndMain) {
            $theme = $site->getSiteTheme();
            if ($theme) {
                SSViewer::set_themes([$theme, SSViewer::DEFAULT_THEME]);
            }
        }

        // Update default uploads folder to site
        $folder = $site->Folder();
        if ($folder->exists()) {
            Config::modify()->set(Upload::class, 'uploads_folder', $folder->Name);
        }
    }
931746
public function onBeforeWrite()
    {
        if ($this->owner instanceof Site) {
            if (!$this->owner->ID) {
                // Initialise a new Site to the top level
                $this->owner->SiteID   = 0;
                $this->owner->ParentID = 0;
            }
            return;
        }

        // Set the SiteID (and ParentID if required) for all new pages.
        if (!$this->owner->ID) {
            $parent = $this->owner->Parent();
            if ($parent && $parent->exists()) {
                // Page is beneath a Site
                if ($parent instanceof Site) {
                    $this->owner->SiteID = $parent->ID;
                } else {
                    $this->owner->SiteID = $parent->SiteID;
                }
            } else {
                // Create the page beneath the current Site
                $this->owner->SiteID   = Multisites::inst()->getDefaultSiteId();
                $this->owner->ParentID = $this->owner->SiteID;
            }
        }

        // Make sure SiteID is changed when site tree is reorganised.
        if ($this->owner->ID && $this->owner->isChanged('ParentID')) {
            // Get the new parent
            $parent = DataObject::get_by_id(SiteTree::class, $this->owner->ParentID);

            // Make sure the parent exists
            if ($parent) {
                // Recursively change SiteID for this and all child pages
                $siteId = ($parent instanceof Site) ? $parent->ID : $parent->SiteID;
                $this->owner->updateSiteID($siteId);
            }
        }
    }
1136487
def prepare_page(self, *args, **kwargs):
        '''
        
        '''
        super(BaseBackend, self).prepare_page(*args, **kwargs)
806290
def home():
    """"""
    return dict(links=dict(api='{}{}'.format(request.url, PREFIX[1:]))), \
        HTTPStatus.OK
1223686
function setUpStates(pages, routeNameParent, parentDirectory) {
            pages.forEach(function (page) {
                if (!page.isBlock && (!page.isStateRef || page.stateRef)) {
                    var routeName = routeNameParent + '.' + page.name;
                    var dirState = routeName.replace('winlassie.', '').split('.');
                    var templateUrl = null;
                    var pageNameReplace = replaceAll(page.name, '_', '-');
                    var state = {url: '/' + pageNameReplace, data: {haveTemplate: false}};

                    // Page cachée ou pas
                    if (typeof page.hidden !== 'undefined') {
                        state.data.hidden = page.hidden;
                    } else {
                        state.data.hidden = false;
                    }

                    // C'est une route d'action (view, create, edit...)
                    if (page.niveauAction) {
                        dirState.pop();
                        state.data.action = page.niveauAction;
                    }

                    // C'est page contient un paramètre requireLogin pour définir si l'utilisateur doit être authentifié
                    if (page.requireLogin) {
                        state.data.requireLogin = page.requireLogin;
                    } else {
                        state.data.requireLogin = true;
                    }

                    // C'est page contient un paramètre requireLogin pour définir si l'utilisateur doit être authentifié
                    if (page.redirectTo) {
                        state.redirectTo = 'winlassie.' + page.redirectTo;
                        state.data.haveTemplate = true;
                    }

                    // Construction du répertoire
                    if (!parentDirectory || isEmpty(parentDirectory) || (page.stateRef && !isEmpty(page.stateRef))) {
                        // Soit on fait référence à une route différente, une sorte d'inclusion, soit on a un fonctionnement normal
                        if (page.stateRef && !isEmpty(page.stateRef)) {
                            dirState = page.stateRef;
                        } else {
                            dirState = dirState.join('/');
                        }
                    } else {
                        dirState = parentDirectory;

                        // Ce n'est pas un niveau, alors on peut concaténé le nom de la page
                        if (!page.niveauAction) {
                            dirState = dirState + '/' + page.name;
                        }
                    }

                    // Titre de la page
                    if (page.title) {
                        state.data.pageTitle = page.title;
                    }

                    // Données suplémentaire pour la route
                    if (page.data) {
                        state.data = Object.assign({}, state.data, page.data);
                    }

                    // Définition de la vue html
                    if (page.views && typeof page.views === 'object') {
                        // On fait référence à une vue qui est le dossier "common"
                        if (page.views.contentCommon) {
                            templateUrl = {templateUrl: 'views/w17_template/common/' + page.views.contentCommon};
                        } else {
                            if (page.views.content && typeof page.views.content === 'object') {
                                templateUrl = Object.assign({}, page.views.content);
                            } else if (typeof page.views.content === 'string') {
                                templateUrl = {templateUrl: 'views/w17_template/' + dirState + '/' + page.views.content};
                            }
                        }

                        // Définition de la vue dans la route pour le conteneur "content" de la route "winlassie"
                        state.views = {
                            'content@winlassie': templateUrl
                        };

                        state.data.haveTemplate = true;

                        // Paramètres de la vue
                        if (page.views.params && Array.isArray(page.views.params) && 0 < page.views.params.length) {
                            var paramsUrl = [];
                            var paramsSearch = [];

                            page.views.params.forEach(function (value) {
                                if (value.startsWith('?')) {
                                    paramsSearch.push(value.substring(1));
                                } else {
                                    paramsUrl.push(value);
                                }
                            });

                            if (0 < paramsUrl.length) {
                                state.url += '/:' + paramsUrl.join('/:');
                            }

                            if (0 < paramsSearch.length) {
                                state.url += '?' + paramsSearch.join('?')
                            }
                        }
                    }

                    states[routeName] = state;

                    if (Array.isArray(page.pages) && 0 < page.pages.length) {
                        setUpStates(page.pages, routeName, dirState);
                    }
                }
            });
        }
1363036
private void setUpDefaultUriComboBox(List<CmsSite> allSites) {

        BeanItemContainer<CmsSite> objects = new BeanItemContainer<CmsSite>(CmsSite.class, allSites);
        m_fieldDefaultURI.setContainerDataSource(objects);
        m_fieldDefaultURI.setNullSelectionAllowed(false);
        m_fieldDefaultURI.setTextInputAllowed(false);
        m_fieldDefaultURI.setItemCaptionPropertyId("title");

        //set value
        String siteRoot = OpenCms.getSiteManager().getDefaultUri();
        if (siteRoot.endsWith("/")) {
            siteRoot = siteRoot.substring(0, siteRoot.length() - 1);
        }
        CmsSite site = OpenCms.getSiteManager().getSiteForSiteRoot(siteRoot);
        m_fieldDefaultURI.setValue(site);
    }
1224594
public void changeSite(String siteRoot, String path, boolean force) {

        CmsObject cms = A_CmsUI.getCmsObject();
        String currentSiteRoot = cms.getRequestContext().getSiteRoot();
        if (force || !currentSiteRoot.equals(siteRoot)) {
            CmsAppWorkplaceUi.get().changeSite(siteRoot);
            if (path == null) {
                path = m_locationCache.getFileExplorerLocation(siteRoot);
                if (CmsStringUtil.isEmptyOrWhitespaceOnly(siteRoot)
                    && ((path == null) || !path.startsWith("/system"))) {
                    // switching to the root site and previous root site folder is not below /system
                    // -> stay in the current folder
                    path = m_locationCache.getFileExplorerLocation(currentSiteRoot);
                    if (path != null) {
                        path = CmsStringUtil.joinPaths(currentSiteRoot, path);
                    }
                }
            }
            openPath(path, true);
            Container container = m_siteSelector.getContainerDataSource();
            for (Object id : container.getItemIds()) {
                String key = (String)id;
                if (CmsStringUtil.comparePaths(key, siteRoot)) {
                    siteRoot = key;
                    break;
                }
            }
            m_siteSelector.select(siteRoot);
        }
    }