Configure the Nikola site for Coil CMS.
355363
def configure_site():
    """"""
    global _site, site, db, q

    nikola.__main__._RETURN_DOITNIKOLA = True
    _dn = nikola.__main__.main([])
    _site = _dn.nikola
    _site.init_plugins()
    _dn.sub_cmds = _dn.get_cmds()
    app.config['NIKOLA_ROOT'] = os.getcwd()
    app.config['DEBUG'] = False

    # Logging configuration

    logf = (u'[{record.time:%Y-%m-%dT%H:%M:%SZ}] {record.level_name}: '
            u'{record.channel}: {record.message}')
    logh = (u'[{record.time:%Y-%m-%dT%H:%M:%SZ}] {record.channel} '
            u'{record.message}')

    loghandlers = [
        ColorfulStderrHandler(level=logbook.DEBUG, format_string=logf,
                              bubble=True),
        logbook.FileHandler('coil.log', 'a', 'utf-8', logbook.DEBUG, logf,
                            bubble=True)
    ]

    hloghandlers = [
        ColorfulStderrHandler(level=logbook.DEBUG, format_string=logh,
                              bubble=True),
        logbook.FileHandler('coil.log', 'a', 'utf-8', logbook.DEBUG, logh,
                            bubble=True)
    ]

    _site.loghandlers = loghandlers
    nikola.utils.LOGGER.handlers = loghandlers

    nikola.plugins.command.new_post.POSTLOGGER.handlers = loghandlers
    nikola.plugins.command.new_post.PAGELOGGER.handlers = loghandlers

    app.config['LOGGER_NAME'] = 'Coil'
    app._logger = get_logger('Coil', loghandlers)
    app.http_logger = get_logger('CoilHTTP', hloghandlers)

    if not _site.configured:
        app.logger("Not a Nikola site.")
        return

    app.secret_key = _site.config.get('COIL_SECRET_KEY')
    app.config['COIL_URL'] = _site.config.get('COIL_URL')
    app.config['COIL_LOGIN_CAPTCHA'] = _site.config.get(
        'COIL_LOGIN_CAPTCHA',
        {'enabled': False, 'site_key': '', 'secret_key': ''})
    app.config['COIL_USERS_PREVENT_EDITING'] = _site.config.get('COIL_USERS_PREVENT_EDITING', [])
    app.config['COIL_LIMITED'] = _site.config.get('COIL_LIMITED', False)
    app.config['REDIS_URL'] = _site.config.get('COIL_REDIS_URL',
                                               'redis://localhost:6379/0')
    if app.config['COIL_LIMITED']:
        app.config['COIL_USERS'] = _site.config.get('COIL_USERS', {})
        _site.coil_needs_rebuild = '0'
    else:
        db = redis.StrictRedis.from_url(app.config['REDIS_URL'])
        q = rq.Queue(name='coil', connection=db)

    _site.template_hooks['menu'].append(generate_menu)
    _site.template_hooks['menu_alt'].append(generate_menu_alt)

    app.config['NIKOLA_URL'] = _site.config['SITE_URL']
    _site.config['NAVIGATION_LINKS'] = {
        _site.default_lang: (
            (app.config['NIKOLA_URL'],
             '<i class="fa fa-globe"></i> View Site'),
            ('http://coil.readthedocs.io/user/',
             '<i class="fa fa-question-circle"></i> Help'),
        )
    }
    _site.GLOBAL_CONTEXT['navigation_links'] = _site.config['NAVIGATION_LINKS']
    TITLE = _site.GLOBAL_CONTEXT['blog_title']() + ' Administration'
    _site.config['BLOG_TITLE'] = TranslatableSetting(
        'BLOG_TITLE', TITLE, _site.config['TRANSLATIONS'])
    _site.GLOBAL_CONTEXT['blog_title'] = _site.config['BLOG_TITLE']
    _site.GLOBAL_CONTEXT['lang'] = _site.default_lang
    _site.GLOBAL_CONTEXT['extra_head_data'] = TranslatableSetting(
        'EXTRA_HEAD_DATA',
        """<link href="//maxcdn.bootstrapcdn.com/font-awesome/4.2.0/css/font-awesome.min.css" rel="stylesheet">\n<link href="/coil_assets/css/coil.css" rel="stylesheet">""",
        _site.config['TRANSLATIONS'])
    # HACK: body_end appears after extra_js from templates, so we must use
    #       social_buttons_code instead
    _site.GLOBAL_CONTEXT['social_buttons_code'] = TranslatableSetting(
        'SOCIAL_BUTTONS_CODE',
        """<script src="/coil_assets/js/coil.js"></script>""",
        _site.config['TRANSLATIONS'])

    # Theme must inherit from bootstrap3, because we have hardcoded HTML.
    themes = [os.path.basename(x) for x in _site.THEMES]
    bs3 = (('bootstrap3' in themes) or
           ('bootstrap3-jinja' in themes))
    if not bs3:
        app.logger.notice("THEME does not inherit from 'bootstrap3' or "
                          "'bootstrap3-jinja', using 'bootstrap3' instead.")
        _site.config['THEME'] = 'bootstrap3'
        # Reloading some things
        _site._THEMES = None
        _site._get_themes()
        _site._template_system = None
        _site._get_template_system()
        if 'has_custom_css' in _site._GLOBAL_CONTEXT:
            del _site._GLOBAL_CONTEXT['has_custom_css']
        _site._get_global_context()

    tmpl_dir = pkg_resources.resource_filename(
        'coil', os.path.join('data', 'templates', _site.template_system.name))
    if os.path.isdir(tmpl_dir):
        # Inject tmpl_dir low in the theme chain
        _site.template_system.inject_directory(tmpl_dir)

    # Commands proxy (only for Nikola commands)
    _site.commands = nikola.utils.Commands(
        _site.doit,
        None,
        {'cmds': _site._commands}
    )

    # Site proxy
    if app.config['COIL_LIMITED']:
        site = _site
        scan_site()
    else:
        site = SiteProxy(db, _site, app.logger)

    configure_url(app.config['COIL_URL'])
1178213
@Override
    public void configure(Properties configuration) {
        String u = configuration.getProperty(ANDROLOG_REPORTER_POST_URL);
        if (u == null) {
            Log.e(this, "The Property " + ANDROLOG_REPORTER_POST_URL
                    + " is mandatory");
            return;
        }
        try {
            url = new URL(u);
        } catch (MalformedURLException e) {
            Log.e(this, "The Property " + ANDROLOG_REPORTER_POST_URL
                    + " is not a valid url", e);
        }
    }
1223484
protected void initConfiguration(CmsObject cms, I_CmsWidgetParameter param) {

        // set the default bundle key
        m_bundleKey = param.getName();
        // set the default locale for XML contents
        m_locale = cms.getRequestContext().getLocale();
        try {
            I_CmsXmlContentValue value = (I_CmsXmlContentValue)param;
            m_locale = value.getLocale();
        } catch (Exception e) {
            // ignore, this is no XML content
        }

        // check the message bundle
        if (CmsStringUtil.isNotEmptyOrWhitespaceOnly(getConfiguration())) {
            //initialize messages, the optional bundle key name and the optional locale from configuration String
            String bundleName = "";
            List<String> configs = CmsStringUtil.splitAsList(getConfiguration(), '|');
            Iterator<String> i = configs.iterator();
            while (i.hasNext()) {
                String config = i.next();
                if (config.startsWith(OPTION_KEY)) {
                    m_bundleKey = config.substring(OPTION_KEY.length());
                } else if (config.startsWith(OPTION_LOCALE)) {
                    m_locale = CmsLocaleManager.getLocale(config.substring(OPTION_LOCALE.length()));
                } else {
                    bundleName = config;
                }
            }
            // create messages object
            m_messages = new CmsMessages(bundleName, m_locale);
        } else {
            // initialize empty messages object to avoid NPE
            m_messages = new CmsMessages("", m_locale);
        }
    }
850679
public function configure()
    {
        $this->items = [];
        $this->layouts = [];
        $this->includes = [];

        $resolver = $this->createResolver();
        $this->params = $resolver->resolve($this->params);

        switch ($this->params['attribute_syntax']) {
            case 'yaml':
                $this->attributeParser = new AttributeParser(AttributeParser::PARSER_YAML);
                break;
            case 'json':
                $this->attributeParser = new AttributeParser(AttributeParser::PARSER_JSON);
                break;
        }
    }
42495
def init():
    ""

    if not os.path.exists('site.cfg'):
        f = open('site.cfg', 'w')
        f.write(SITECFG)
        f.close()

    try:
        os.mkdir('queries')
    except OSError:
        pass

    try:
        os.mkdir('templates')
    except OSError:
        pass

    htmlfile = os.path.join('templates', 'homepage.html')
    if not os.path.exists(htmlfile):
        f = open(htmlfile, 'w')
        f.write("""
<!doctype html>
<html>
    <head>
        <title>Chill</title>
    </head>
    <body>
        <p>{{ homepage_content }}</p>
    </body>
</html>
        """)
        f.close()

    app = make_app(config='site.cfg', DEBUG=True)

    with app.app_context():
        app.logger.info("initializing database")
        init_db()

        homepage = insert_node(name='homepage', value=None)
        insert_route(path='/', node_id=homepage)
        insert_query(name='select_link_node_from_node.sql', node_id=homepage)

        add_template_for_node('homepage.html', homepage)

        homepage_content = insert_node(name='homepage_content', value="Cascading, Highly Irrelevant, Lost Llamas")
        insert_node_node(node_id=homepage, target_node_id=homepage_content)
1173044
public function configure()
    {
        parent::configure();

        /** @var \Symfony\Component\HttpFoundation\Session\Session $session */
        $session = $this->get('session');

        switch (strtolower($this->container->getParameter('networking_init_cms.db_driver'))) {
            case 'monodb':
                $lastEditedSubscriber = new ODMLastEditedListener($session);
                break;
            case 'orm':
                $lastEditedSubscriber = new ORMLastEditedListener($session);
                break;
            default:
                $lastEditedSubscriber = false;
                break;
        }

        if ($lastEditedSubscriber) {
            $this->dispatcher->addSubscriber($lastEditedSubscriber);
        }
    }
804401
private void initSite() {

        Object o = null;
        if (CmsStringUtil.isEmpty(getParamAction()) || CmsDialog.DIALOG_INITIAL.equals(getParamAction())) {
            // this is the initial dialog call
            if (CmsStringUtil.isNotEmpty(m_paramSites)) {
                // edit an existing site, get it from manager
                o = OpenCms.getSiteManager().getSiteForSiteRoot(m_paramSites);
            }
        } else {
            // this is not the initial call, get site from session
            o = getDialogObject();
        }
        if (o instanceof CmsSite) {
            // reuse site stored in session
            m_site = new CmsSiteBean((CmsSite)o);
        } else if (o instanceof CmsSiteBean) {
            // create a new site
            m_site = (CmsSiteBean)o;
        } else if (DIALOG_NEW.equals(getParamEditaction())) {
            m_site = new CmsSiteBean();
        } else {
            try {
                getToolManager().jspForwardTool(this, "/sites", new HashMap<String, String[]>());
            } catch (Exception e) {
                // noop
            }
        }

        if (!m_site.hasSecureServer()) {
            m_site.setSecureUrl("");
        }
        try {
            CmsObject clone = OpenCms.initCmsObject(getCms());
            clone.getRequestContext().setSiteRoot("");
            String iconPath = m_site.getSiteRoot() + "/" + CmsSiteFaviconDialog.ICON_NAME;
            if (clone.existsResource(iconPath)) {
                m_site.setFavicon(iconPath);
            }
        } catch (Throwable t) {
            // noop
        }

        if (m_site.getSiteRoot() != null) {
            setSitename(CmsResource.getName(m_site.getSiteRoot()));
        }

        CmsModule module = OpenCms.getModuleManager().getModule(MODULE_NAME);
        m_createou = Boolean.valueOf(module.getParameter(PARAM_CREATE_OU, Boolean.FALSE.toString())).booleanValue();
        m_ouDescription = module.getParameter(PARAM_OU_DESCRIPTION, "OU for: %(site)");
        setDialogObject(m_site);
    }
197712
public void configure(String rootUrl, Settings settings) {
    Data<Read, ReadGroupSet, Reference> data = dataSources.get(rootUrl);
    if (data == null) {
      data = new Data<Read, ReadGroupSet, Reference>(settings, null);
      dataSources.put(rootUrl, data);
    } else {
      data.settings = settings;
    }
  }
886301
def rebuild(mode=''):
    """"""
    scan_site()  # for good measure
    if not current_user.can_rebuild_site:
        return error('You are not permitted to rebuild the site.</p>'
                     '<p class="lead">Contact an administartor for '
                     'more information.', 401)
    if db is not None:
        db.set('site:needs_rebuild', '-1')
        if not q.fetch_job('build') and not q.fetch_job('orphans'):
            b = q.enqueue_call(func=coil.tasks.build,
                               args=(app.config['REDIS_URL'],
                                     app.config['NIKOLA_ROOT'], mode),
                               job_id='build')
            q.enqueue_call(func=coil.tasks.orphans,
                           args=(app.config['REDIS_URL'],
                                 app.config['NIKOLA_ROOT']), job_id='orphans',
                           depends_on=b)
        return render('coil_rebuild.tmpl', {'title': 'Rebuild'})
    else:
        status, outputb = coil.tasks.build_single(mode)
        _, outputo = coil.tasks.orphans_single()
        site.coil_needs_rebuild = '0'
        return render('coil_rebuild_single.tmpl',
                      {'title': 'Rebuild', 'status': '1' if status else '0',
                       'outputb': outputb, 'outputo': outputo})
317552
protected function configure()
    {
        $this->aroot = realpath($this->root);
        $root = $this->stat($this->root);

        if ($this->options['quarantine']) {
            $this->attributes[] = array(
                'pattern' => '~^'.preg_quote(DIRECTORY_SEPARATOR.$this->options['quarantine']).'$~',
                'read'    => false,
                'write'   => false,
                'locked'  => true,
                'hidden'  => true
            );
        }

        // chek thumbnails path
        if ($this->options['tmbPath']) {
            $this->options['tmbPath'] = strpos($this->options['tmbPath'], DIRECTORY_SEPARATOR) === false
                // tmb path set as dirname under root dir
                ? $this->root.DIRECTORY_SEPARATOR.$this->options['tmbPath']
                // tmb path as full path
                : $this->_normpath($this->options['tmbPath']);
        }

        parent::configure();

        // if no thumbnails url - try detect it
        if ($root['read'] && !$this->tmbURL && $this->URL) {
            if (strpos($this->tmbPath, $this->root) === 0) {
                $this->tmbURL = $this->URL.str_replace(DIRECTORY_SEPARATOR, '/', substr($this->tmbPath, strlen($this->root)+1));
                if (preg_match("|[^/?&=]$|", $this->tmbURL)) {
                    $this->tmbURL .= '/';
                }
            }
        }

        // check quarantine dir
        if (!empty($this->options['quarantine'])) {
            $this->quarantine = $this->root.DIRECTORY_SEPARATOR.$this->options['quarantine'];
            if ((!is_dir($this->quarantine) && !$this->_mkdir($this->root, $this->options['quarantine'])) || !is_writable($this->quarantine)) {
                $this->archivers['extract'] = array();
                $this->disabled[] = 'extract';
            }
        } else {
            $this->archivers['extract'] = array();
            $this->disabled[] = 'extract';
        }

    }
1278145
def configure(host=DEFAULT_HOST, port=DEFAULT_PORT):
    
    global __logger
    __logger = UDPLogger(host, port)
327948
def _parse_website_config(self, (response, xml_bytes)):
        """"""
        root = XML(xml_bytes)
        index_suffix = root.findtext("IndexDocument/Suffix")
        error_key = root.findtext("ErrorDocument/Key")

        return WebsiteConfiguration(index_suffix, error_key)
1233393
private function initSite()
    {
        $this->site = new Eresus_Site($this->getLegacyKernel());
        $this->site->setTitle(siteTitle);
        $this->site->setDescription(siteDescription);
        $this->site->setKeywords(siteKeywords);
        TemplateSettings::setGlobalValue('site', $this->site);
    }
325818
def configure(name, host, port, auth, current):
    '''
    
    '''
    Config = ConfigParser.ConfigParser()
    if not os.path.exists(os.path.dirname(filename)):
        try:
            os.makedirs(os.path.dirname(filename))
        except Exception as e:
            click.echo(e)
            return
    section_name = None
    if(current.lower() == 'y'):
        section_name = 'Current'
        change_current()
    else:
        section_name = name.capitalize()
    cfgfile = open(filename,'a')
    Config.add_section(section_name)
    Config.set(section_name,'host',host)
    Config.set(section_name,'port',port)
    Config.set(section_name,'auth',auth)
    Config.set(section_name,'name',name.capitalize())
    Config.write(cfgfile)
    cfgfile.close()
174601
@Override
    protected void configure() {

        // Create HK2 service locator and bind jersey injections
        ServiceLocator locator = ServiceLocatorFactory.getInstance().create(null);
        bind(ServiceLocator.class).toInstance(locator);

        bind(VertxContainer.class).to(DefaultVertxContainer.class);
        bind(JerseyServer.class).to(GuiceJerseyServer.class);
        bind(JerseyHandler.class).to(DefaultJerseyHandler.class);
        bind(JerseyOptions.class).to(DefaultJerseyOptions.class);
        bind(JerseyServerOptions.class).to(DefaultJerseyOptions.class);
        bind(ContainerResponseWriterProvider.class).to(VertxResponseWriterProvider.class);
        bind(MessageBodyWriter.class).to(WriteStreamBodyWriter.class).in(Singleton.class);
        bind(ApplicationConfigurator.class).toProvider(Providers.of(null));

        Multibinder.newSetBinder(binder(), VertxRequestProcessor.class);
        Multibinder.newSetBinder(binder(), VertxResponseProcessor.class);
        Multibinder.newSetBinder(binder(), VertxPostResponseProcessor.class);

        Multibinder.newSetBinder(binder(), ContainerRequestFilter.class);
        Multibinder.newSetBinder(binder(), ContainerResponseFilter.class);
        Multibinder.newSetBinder(binder(), ReaderInterceptor.class);
        Multibinder.newSetBinder(binder(), WriterInterceptor.class);
        Multibinder.newSetBinder(binder(), ModelProcessor.class);
        Multibinder.newSetBinder(binder(), ContainerLifecycleListener.class);
        Multibinder.newSetBinder(binder(), ApplicationEventListener.class);
        Multibinder.newSetBinder(binder(), ExceptionMapper.class);

    }
746471
public void configure(CmsObject cms) {

        if (CmsLog.INIT.isInfoEnabled()) {
            CmsLog.INIT.info(Messages.get().getBundle().key(Messages.INIT_TOOLMANAGER_CREATED_0));
        }
        if (m_roots.getObject(ROOTKEY_DEFAULT) == null) {
            CmsToolRootHandler defToolRoot = new CmsToolRootHandler();
            defToolRoot.setKey(ROOTKEY_DEFAULT);
            defToolRoot.setUri(CmsWorkplace.PATH_WORKPLACE + "admin/");
            defToolRoot.setName("${key." + Messages.GUI_ADMIN_VIEW_ROOT_NAME_0 + "}");
            defToolRoot.setHelpText("${key." + Messages.GUI_ADMIN_VIEW_ROOT_HELP_0 + "}");
            addToolRoot(defToolRoot);
        }
        m_tools.clear();
        m_urls.clear();
        Iterator<CmsToolRootHandler> it = getToolRoots().iterator();
        while (it.hasNext()) {
            CmsToolRootHandler toolRoot = it.next();
            if (!cms.existsResource(toolRoot.getUri())) {
                if (CmsLog.INIT.isInfoEnabled()) {
                    CmsLog.INIT.info(
                        Messages.get().getBundle().key(
                            Messages.INIT_TOOLMANAGER_ROOT_SKIPPED_2,
                            toolRoot.getKey(),
                            toolRoot.getUri()));
                }
                continue;
            }
            try {
                toolRoot.setup(cms, null, toolRoot.getUri());
                configureToolRoot(cms, toolRoot);
                // log info
                if (CmsLog.INIT.isInfoEnabled()) {
                    CmsLog.INIT.info(
                        Messages.get().getBundle().key(Messages.INIT_TOOLMANAGER_SETUP_1, toolRoot.getKey()));
                }
            } catch (CmsException e) {
                // log failure
                if (CmsLog.INIT.isWarnEnabled()) {
                    CmsLog.INIT.warn(
                        Messages.get().getBundle().key(Messages.INIT_TOOLMANAGER_SETUP_ERROR_1, toolRoot.getKey()),
                        e);
                }
            }
        }
    }
819499
def configure(self, rhsm=None, repositories=None):
        """"""
        if rhsm is not None:
            self.rhsm_register(rhsm)
        if repositories is not None:
            self.enable_repositories(repositories)
        self.create_stack_user()
        self.deploy_hypervisor()