Function used to send static theme files from the theme folder to the browser.
326875
def send_theme_file(self, filename):
        
        cache_timeout = self.get_send_file_max_age(filename)
        return send_from_directory(self.config['THEME_STATIC_FOLDER'], filename,
                                   cache_timeout=cache_timeout)
660639
private static function http()
    {
        $files = ['Http', 'Request'];
        $folder = static::$root.'Http'.'/';

        self::call($files, $folder);

        static::links();
        static::redirect();
        static::middleware();
    }
1058072
function generateTheme({
  stylesDir,
  mainLessFile,
  varFile,
  outputFilePath,
  themeVariables
}) {
  return new Promise((resolve, reject) => {
    /*
      You own custom styles (Change according to your project structure)
      
      - stylesDir - styles directory containing all less files
      - varFile - variable file containing your custom variables
      - mainLessFile - less main file which imports all styles
    */
    let content = '';
    // const hashCode = hash.sha256().update(content).digest('hex');
    // if(hashCode === hashCache){
    //   resolve(cssCache);
    //   return;
    // }
    // hashCache = hashCode;
    let themeCompiledVars = {};
    let themeVars = themeVariables || [];
    const lessPaths = [
      stylesDir
    ];

    return bundle({
      src: varFile
    })
      .then(colorsLess => {
        const mappings = Object.assign(generateColorMap(colorsLess), mainLessFile? generateColorMap(mainLessFile): {});
        return [mappings, colorsLess];
      })
      .then(([mappings, colorsLess]) => {
        let css = "";
        /*
         If not pass in themeVariables, the variables in varFile will be used
         */
        if (!themeVariables) {
            let varJs = lessToJs(fs.readFileSync(varFile, 'utf8'));
            themeVars.forEach(varName => {
                delete varJs[varName];
            });
            themeVars.push(...Object.keys(varJs));
        }
        if (!themeVars.length) {
            themeVars.push("@theme-color");
        }
        themeVars = themeVars.filter(name => name in mappings);
        themeVars.forEach(varName => {
          const color = mappings[varName];
          css = `.${varName.replace("@", "")} { color: ${color}; }\n ${css}`;
        });

        css = `${colorsLess}\n${css}`;
        return render(css, lessPaths).then(({ css }) => [
          css,
          mappings,
          colorsLess
        ]);
      })
      .then(([css, mappings, colorsLess]) => {
        css = css.replace(/(\/.*\/)/g, "");
        const regex = /.(?=\S*['-])([.a-zA-Z0-9'-]+)\ {\n\ \ color:\ (.*);/g;
        themeCompiledVars = getMatches(css, regex);
        content = `${content}\n${colorsLess}`;
        return render(content, lessPaths).then(({ css }) => {
          return getCssModulesStyles(stylesDir).then(customCss => {
            return [
              `${customCss}\n${css}`,
              mappings,
              colorsLess
            ];
          })
          
        });
      })
      .then(([css, mappings, colorsLess]) => {
        return postcss([reducePlugin(themeCompiledVars)])
          .process(css, {
            parser: less.parser,
            from: mainLessFile | varFile
          })
          .then(({ css }) => [css, mappings, colorsLess]);
      })
      .then(([css, mappings, colorsLess]) => {
        Object.keys(themeCompiledVars).forEach(varName => {
          let color;
          if (/(.*)-(\d)/.test(varName)) {
            color = themeCompiledVars[varName];
            varName = getShade(varName);
          } else {
            color = themeCompiledVars[varName];
          }
          color = color.replace('(', '\\(').replace(')', '\\)');
          css = css.replace(new RegExp(`${color}`, "g"), varName);
        });

        css = `${colorsLess}\n${css}`;

        themeVars.reverse().forEach(varName => {
          css = css.replace(new RegExp(`${varName}(\ *):(.*);`, 'g'), '');
          css = `${varName}: ${mappings[varName]};\n${css}\n`;
        });
        css = css.replace(/\n+/g, '\n');

        css = uniqueCss(css);

        if (outputFilePath) {
          fs.writeFileSync(outputFilePath, css);
          console.log(
            `Theme generated successfully. OutputFile: ${outputFilePath}`
          );
        } else {
          console.log(`Theme generated successfully`);
        }
        cssCache = css;
        return resolve(css);
      })
      .catch(err => {
        console.log("Error", err);
        reject(err);
      });
  });
}
420308
function () {
                var added = {},
                    current,
                    newStatus;

                current = this.stylesheets;
                newStatus = related().stylesheets;

                Object.keys(newStatus).forEach(function (v, i) {
                    if (!current[v]) {
                        added[v] = newStatus[v];
                    }
                });

                Object.keys(added).forEach(function (v, i) {
                    _transport.send(JSON.stringify({
                        method: "StylesheetAdded",
                        href: v,
                        roots: [added[v]]
                    }));
                });

                this.stylesheets = newStatus;
            }
112572
function() {
    if (typeof this.themeData !== 'string') {
      if (this.themeFile) {
        this.themeFile = path.resolve(this.cwd, this.themeFile);
        this.themeData = fs.readFileSync(this.themeFile, 'utf-8');
      } else {
        this.loadThemeVars();
        this.themeData = this.varsData;
      }
      this.setThemeVars(this.themeData);
    }
  }
234447
def staticflatpage(request, path):
    """"""
    # Don't render a base.html template.
    if path.replace("/", '').lower() == "base":
        raise Http404

    if not path.startswith('/'):
        path = "/{0}".format(path)
    if path.endswith('/'):
        path = path[:-1]

    # Support for index.html templates.
    if path == '':
        path = "/index"

    # paths should be in the format: staticflatpages/path/from/url.html
    path = "staticflatpages{0}.html".format(path)
    try:
        return render(request, path)
    except TemplateDoesNotExist:
        raise Http404
253917
def static!(options = {})
      return if (public_dir = settings.public_folder).nil?
      path = File.expand_path("#{public_dir}#{URI_INSTANCE.unescape(request.path_info)}" )
      return unless File.file?(path)

      env['sinatra.static_file'] = path
      cache_control(*settings.static_cache_control) if settings.static_cache_control?
      send_file path, options.merge(:disposition => nil)
    end
947102
function renderThemeTree(themeId, fileList, themeName) {
        var getTreeNodes = function (arr) {
            var ret = [];
            _.each(arr, function (fileName) {
                ret.push({title:fileName});
            });
            return ret;
        };
        var css = {title:validTitleName[0], isFolder:true, children:getTreeNodes(fileList["css"])},
            js = {title:validTitleName[1], isFolder:true, children:getTreeNodes(fileList["js"])},
            images = {title:validTitleName[2], isFolder:true, children:getTreeNodes(fileList["images"])},
            tmpl = {title:validTitleName[3], isFolder:true, children:getTreeNodes(fileList["tmpl"])},
            children = [css, images, js, tmpl];
        tree = treeObj.dynatree({
                onActivate:function (node) {
                    var data = node.data;
                    if (!data.isFolder) {
                        openFile(themeId, node.parent.data.title, data.title);
                    }
                    else {
                        hideEditor();
                        hideImageHolder();
                    }
                },
                children:{title:themeName, children:children, isFolder:true, expand:true}
            }
        );
        $(tree).dynatree("getTree").reload();
    }
424777
def format_theme(selection):
    """"""
    global themefile

    text = open(THEMEDIR + '/' + selection).read()
    if '!dotcolors' in text[:10]:
        themefile = text
        return

    lines = ['!dotcolors auto formatted\n']
    for line in text.split('\n'):
        lline = line.lower()
        background = 'background' in lline
        foreground = 'foreground' in lline
        color = 'color' in lline

        if background:
            if 'rgb' in line:
                # rbga: 0000/0000/0000/dddd
                rgb = line.split(':')[2].replace(' ', '')
                rgb = rgb_to_hex(rgb)
                lines.append('*background:\t%s' % rgb)
            else:
                lines.append('\t#'.join(line \
                                        .replace(' ', '') \
                                        .replace('\t', '') \
                                        .split('#')))

        if foreground:
            if 'rgb' in line:
                # rbga: 0000/0000/0000/dddd
                rgb = line.split(':')[2].replace(' ', '')
                rgb = rgb_to_hex(rgb)
                lines.append('*foreground:\t%s' % rgb)
            else:
                lines.append('\t#'.join(line \
                                        .replace(' ', '') \
                                        .replace('\t', '') \
                                        .split('#')))

        if color:
            if lline[0] != '!':
                lines.append('\t#'.join(line \
                                        .replace(' ', '') \
                                        .replace('\t', '') \
                                        .split('#')))
    
    themefile = '\n'.join(lines) + '\n'
    fd, tmpfile = tempfile.mkstemp()
    if exists( THEMEDIR + '/' + selection ):
        old = open( THEMEDIR + '/' + selection )
        new = os.fdopen(fd, 'w')
        os.write(fd, themefile)
        old.close()
        new.close()
        move( tmpfile, THEMEDIR + '/' + selection )
818736
function loadCurrentTheme() {
        var theme = getCurrentTheme();

        var pending = theme && FileUtils.readAsText(theme.file)
            .then(function (lessContent) {
                return lessifyTheme(lessContent.replace(commentRegex, ""), theme);
            })
            .then(function (content) {
                var result = extractScrollbars(content);
                theme.scrollbar = result.scrollbar;
                return result.content;
            })
            .then(function (cssContent) {
                $("body").toggleClass("dark", theme.dark);
                styleNode.text(cssContent);
                return theme;
            });

        return $.when(pending);
    }
806708
function PrettyPageHandler(theme, pageTitle, editor, sendResponse, additionalScripts) {

    PrettyPageHandler.super_.call(this);

    /**
     * @var {String}
     * @protected
     */
    this.__pageTitle = pageTitle || "Ouch! There was an error.";

    /**
     * @var {String}
     * @protected
     */
    this.__theme = theme || "blue";

    /**
     * A string identifier for a known IDE/text editor, or a closure
     * that resolves a string that can be used to open a given file
     * in an editor. If the string contains the special substrings
     * %file or %line, they will be replaced with the correct data.
     *
     * @example
     *  "txmt://open?url=%file&line=%line"
     *
     * @var {*} editor
     * @protected
     */
    this.__editor = editor;

    /**
     * Should Ouch push output directly to the client?
     * If this is false, output will be passed to the callback
     * provided to the handle method.
     * @type {boolean}
     * @protected
     */
    this.__sendResponse = sendResponse === undefined ? true : Boolean(sendResponse);

    /**
     * An Array of urls that represent additional javascript resources to include in the rendered template.
     *
     * @type {Array}
     * @protected
     */
    this.__additionalScripts = additionalScripts || [];

    /**
     * A list of known editor strings
     *
     * @var Object
     * @protected
     */
    this.__editors = {
        "sublime": "subl://open?url=file://%file&line=%line",
        "textmate": "txmt://open?url=file://%file&line=%line",
        "emacs": "emacs://open?url=file://%file&line=%line",
        "macvim": "mvim://open/?url=file://%file&line=%line"
    };
}
1042999
function resolveStylesheet(file, pathes) {
    var filePath = file.path,
        linkStr = '';

    for(var i = 0, len = pathes.length; i < len; i ++) {
        linkStr += '<link rel="stylesheet" href="' + path.relative(path.dirname(filePath), pathes[i]) + '"/>\r\n';
    }

    return linkStr;
}
1287650
private static function links()
    {
        $files = ['Link'];
        $folder = static::$root.'Http/Links'.'/';

        self::call($files, $folder);

        $files = ['LinkKeyNotFoundException'];
        $folder = static::$root.'Http/Links/Exceptions'.'/';

        self::call($files, $folder);
    }
825461
def create_templates_static_files(app_path):
    
    templates_path = os.path.join(app_path, 'templates')
    static_path = os.path.join(app_path, 'static')
    _mkdir_p(templates_path)
    _mkdir_p(static_path)
    # create {img, css, js}
    os.chdir(static_path)
    img_path = os.path.join(static_path, 'img')
    css_path = os.path.join(static_path, 'css')
    js_path = os.path.join(static_path, 'js')
    _mkdir_p(img_path)
    _mkdir_p(css_path)
    _mkdir_p(js_path)

    return css_path, templates_path
1118150
function loadThemeTranslations() {
        // This function is called during theme initialization, and when switching language or theme.
        currentLocale = I18n.locale();
        activeTheme = settingsCache.get('active_theme');

        // Reading file for current locale and active theme and keeping its content in memory
        if (activeTheme) {
            // Reading translation file for theme .hbs templates.
            // Compatibility with both old themes and i18n-capable themes.
            // Preventing missing files.
            try {
                themeStrings = fs.readFileSync(path.join(config.getContentPath('themes'), activeTheme, 'locales', currentLocale + '.json'));
            } catch (err) {
                themeStrings = undefined;
                if (err.code === 'ENOENT') {
                    if (currentLocale !== 'en') {
                        logging.warn(`Theme's file locales/${currentLocale}.json not found.`);
                    }
                } else {
                    throw err;
                }
            }
            if (themeStrings === undefined && currentLocale !== 'en') {
                logging.warn('Falling back to locales/en.json.');
                try {
                    themeStrings = fs.readFileSync(path.join(config.getContentPath('themes'), activeTheme, 'locales', 'en.json'));
                } catch (err) {
                    themeStrings = undefined;
                    if (err.code === 'ENOENT') {
                        logging.warn('Theme\'s file locales/en.json not found.');
                    } else {
                        throw err;
                    }
                }
            }
            if (themeStrings !== undefined) {
                // if translation file is not valid, you will see an error
                try {
                    themeStrings = JSON.parse(themeStrings);
                } catch (err) {
                    themeStrings = undefined;
                    throw err;
                }
            }
        }

        if (themeStrings === undefined) {
            // even if empty, themeStrings must be an object for jp.value
            themeStrings = {};
        }

        _private.initializeIntl();
    }
538449
function() {
    if (typeof this.varsData !== 'string') {
      if (!this.varsFile) throw 'No theme variables file specified.';
      this.varsFile = path.resolve(this.cwd, this.varsFile);
      this.varsData = fs.readFileSync(this.varsFile, 'utf-8');
    }
  }
112363
def get_html_theme_path():
    
    return os.path.abspath(os.path.dirname(os.path.dirname(__file__)))