Private: append a nonce to the script/style directories if script_nonce
 or style_nonce are provided.
2769
def populate_nonces(directive, source_list)
      case directive
      when SCRIPT_SRC
        append_nonce(source_list, @script_nonce)
      when STYLE_SRC
        append_nonce(source_list, @style_nonce)
      else
        source_list
      end
    end
959268
def cache_dir(script)
      # prefix object ID with a text constant to make a legal directory name
      # in case object id is negative (Ubuntu, etc.). this method will be called
      # more than once and must return the same directory each time for a given
      # script instantiation.
      path = File.normalize_path(File.join(AgentConfig.cache_dir, 'right_scripts_content', "rs_attach" + script.object_id.to_s))

      # convert to native format for ease of scripting in Windows, etc. the
      # normalized path is normal for Ruby but not necessarily for native FS.
      return RightScale::Platform.filesystem.pretty_path(path, true)
    end
1274764
function IncludeMiddleware(options) {
  var self = this;

  // Initialize with passed in configuration or empty arrays.
  self.globalStyles = (options && options.globalStyles) ? options.globalStyles : [];
  self.globalScripts = (options && options.globalScripts) ? options.globalScripts : [];
  self.sectionDefinition = (options && options.sectionDefinition) ? options.sectionDefinition : [];
  self.pageDefinition = (options && options.pageDefinition) ? options.pageDefinition : [];

  // Initialize minified files.
  self.minified = (options && options.minified) ? options.minified : false;
  self.dirName = (options && options.dirName) ? (options.dirName) : null;
  
  // Objects that hold cached css and js files both full and minified.
  self.scriptFiles = {};
  self.styleFiles = {};

  // This looks really ugly. But the point here is to read all the css files that
  // are defined anywhere into memory, minify them in order to get them ready to 
  // go for actual requests.
  if (self.minified && self.dirName) {

    // Get a listing of folders underneath the directory given.
    self.dirs = getFoldersRecursive(self.dirName);

    // Loop through defined global styles.
    self.globalStyles.forEach(function(element, index, array) {
      var source = minify.readAndMinifyCSS(self.dirName + '/' + self.globalStyles[index], self.dirs);
      self.styleFiles[self.globalStyles[index]] = source;
    });

    // Loop through defined global scripts.
    self.globalScripts.forEach(function(element, index, array) {
      var source = minify.readAndMinifyJS(self.dirName + '/' + self.globalScripts[index]);
      self.scriptFiles[self.globalScripts[index]] = source;
    });

    // Loop through defined section definitions.
    self.sectionDefinition.forEach(function(sectionElement, sectionIndex, sectionArray) {

      // styles
      self.sectionDefinition[sectionIndex].styles.forEach(function(el, i, arr) {
        var source = minify.readAndMinifyCSS(self.dirName + '/' + self.sectionDefinition[sectionIndex].styles[i], self.dirs);
        self.styleFiles[self.sectionDefinition[sectionIndex].styles[i]] = source;
      });

      // scripts
      self.sectionDefinition[sectionIndex].scripts.forEach(function(el, i, arr) {
        var source = minify.readAndMinifyJS(self.dirName + '/' + self.sectionDefinition[sectionIndex].scripts[i]);
        self.scriptFiles[self.sectionDefinition[sectionIndex].scripts[i]] = source;
      });

    });

    // Loop through defined page definitions.
    self.pageDefinition.forEach(function(pageElement, pageIndex, pageArray) {

      // styles
      self.pageDefinition[pageIndex].styles.forEach(function(el, i, arr) {
        var source = minify.readAndMinifyCSS(self.dirName + '/' + self.pageDefinition[pageIndex].styles[i], self.dirs);
        self.styleFiles[self.pageDefinition[pageIndex].styles[i]] = source;
      });

      // scripts
      self.pageDefinition[pageIndex].scripts.forEach(function(el, i, arr) {
        var source = minify.readAndMinifyJS(self.dirName + '/' + self.pageDefinition[pageIndex].scripts[i]);
        self.scriptFiles[self.pageDefinition[pageIndex].scripts[i]] = source;
      });

    });

  }

  /**
   * Express middleware function that gets imports for the current 
   * page and attaches them to `res.locals` object, then calls next(). 
   */
  self.mwFn = function(req, res, next) {
    var imports = self.getImports(url.parse(req.url).pathname);
    res.locals.scripts = imports.scripts;
    res.locals.styles = imports.styles;
    next();
  };

  /**
   * 
   */
  self.mwFnMinified = function(req, res, next) {
    var imports = self.getImports(url.parse(req.url).pathname);
    res.locals.scripts = imports.scripts;
    res.locals.styles = imports.styles;

    res.locals.cssSource = '';
    res.locals.cssSourceMin = '';
    res.locals.jsSource = '';
    res.locals.jsSourceMin = '';

    res.locals.styles.forEach(function(el, index, arr) {
      res.locals.cssSource += self.styleFiles[res.locals.styles[index]].full;
      res.locals.cssSourceMin += self.styleFiles[res.locals.styles[index]].min;
    });

    res.locals.scripts.forEach(function(el, index, arr) {
      res.locals.jsSource += self.scriptFiles[res.locals.scripts[index]].full;
      res.locals.jsSourceMin += self.scriptFiles[res.locals.scripts[index]].min;
    });

    next();
  };

  /**
   * Takes in a url and finds a section configuration from what was 
   * passed in earlier. At this time it can only return 1 section 
   * configuration, or null if none are found.
   * 
   * // TODO: ability to return multiple section configs? 
   */
  self.getSectionConfig = function(url) {
    if (!url) return null;

    for (var i = 0; i < self.sectionDefinition.length; i++) {
      if (url.indexOf(self.sectionDefinition[i].url) > -1) {
        return self.sectionDefinition[i];
      }
    }
    return null;
  };

  /**
   * Breaks down the url and each of the page definitions that were
   * passed in, and determines if there's a match. This function can 
   * currently only return one page config. 
   * 
   * TODO: ability to return multiple page configs?
   */
  self.getPageConfig = function(url) {
      if (!url) return null;
      var urlParts = url.split("/");

      for (var i = 0; i < self.pageDefinition.length; i++) {
          var itPageParts = self.pageDefinition[i].url.split("/");

          if (urlParts.length === itPageParts.length) {
              var match = true;

              for (var j = 0; j < itPageParts.length; j++) {
                  if (itPageParts[j] === ":") continue;
                  if (itPageParts[j] !== urlParts[j]) match = false;
              }

              if (match) {
                return self.pageDefinition[i];
              }
          }
      }
      return null;
  };

  /**
   * Top-level function that uses `getSectionConfig` and `getPageConfig`.
   * This function combines all of the imports that should go with the
   * page including each of the three layers (global, section and page). 
   */
  self.getImports = function(url) {
    var styles = self.globalStyles;
    var scripts = self.globalScripts;

    // Find section, append styles and scripts if section found.
    var sectionConfig = self.getSectionConfig(url);
    if (sectionConfig) {
      if (sectionConfig.styles && Array.isArray(sectionConfig.styles))
        styles = styles.concat(sectionConfig.styles);
      if (sectionConfig.scripts && Array.isArray(sectionConfig.scripts))
        scripts = scripts.concat(sectionConfig.scripts);
    }

    // Find page, append styles and scripts if page found.
    var pageConfig = self.getPageConfig(url);
    if (pageConfig) {
      if (pageConfig.styles && Array.isArray(pageConfig.styles))
        styles = styles.concat(pageConfig.styles);
      if (pageConfig.scripts && Array.isArray(pageConfig.scripts))
        scripts = scripts.concat(pageConfig.scripts);
    }

    // Return the entire list of styles, scripts and configs.
    return {
      styles: styles,
      scripts: scripts,
      pageConfig: pageConfig,
      sectionConfig: sectionConfig
    };
  };

  // Return myself.
  return self;
}
885261
def _add_cli_scripts(self):
        ''''''

        pattern = r"cli script\s+" \
                  r"(\/[\w\.\-]+\/)?" \
                  r"(?P<name>[\w\.\-]+)\s*\{"
        sections = re.finditer(pattern, self.template_str)

        for section in sections:
            if 'scripts' not in self.templ_dict:
                self.templ_dict['scripts'] = []

            try:
                sec_start = self._get_section_start_index(
                    section.group('name')
                )
            except NonextantSectionException:
                continue

            sec_end = self._get_section_end_index(
                section.group('name'), sec_start
            )
            section_value = self.template_str[sec_start+1:sec_end].strip()

            self.templ_dict['scripts'].append(dict(
                name=section.group('name'),
                script=section_value
            ))

            self.template_str = self.template_str[:sec_start+1] + \
                self.template_str[sec_end:]
938971
public void addScriptProperties(Content head) {
        HtmlTree javascript = HtmlTree.SCRIPT(pathToRoot.resolve(DocPaths.JAVASCRIPT).getPath());
        head.addContent(javascript);
        if (configuration.createindex) {
            if (pathToRoot != null && script != null) {
                String ptrPath = pathToRoot.isEmpty() ? "." : pathToRoot.getPath();
                script.addContent(new RawHtml("var pathtoroot = \"" + ptrPath + "/\";loadScripts(document, \'script\');"));
            }
            addJQueryFile(head, DocPaths.JSZIP_MIN);
            addJQueryFile(head, DocPaths.JSZIPUTILS_MIN);
            head.addContent(new RawHtml("<!--[if IE]>"));
            addJQueryFile(head, DocPaths.JSZIPUTILS_IE_MIN);
            head.addContent(new RawHtml("<![endif]-->"));
            addJQueryFile(head, DocPaths.JQUERY_JS_1_10);
            addJQueryFile(head, DocPaths.JQUERY_JS);
        }
    }
301967
def append_to_path (path, directory):
    """"""
    if not os.path.isdir(directory) or directory in path:
        return path
    if not path.endswith(os.pathsep):
        path += os.pathsep
    return path + directory
29563
public function add_js( $path, $nonblocking = false )
	{
		if( $nonblocking )
		{
			$this->_nonblocking_js_ []= '<script type="text/javascript" src="'.$path.'"></script>' . chr(10) . chr(13);
		}
		else
		{
			$this->_js_ []= '<script type="text/javascript" src="'.$path.'"></script>' . chr(10) . chr(13);
		}
	}
1202076
def prepend_rez_path(self):
        """"""
        if system.rez_bin_path:
            self.env.PATH.prepend(system.rez_bin_path)
349285
def add_jsfile_head(self, src: str) -> None:
        """"""
        self.head.appendChild(Script(src=src))
693516
function (file, context, opts) {
        if (!opts.autoInsertPlaceholder) {
            return;
        }
        file._initScriptPlacedholder || parsePackScript(file, context, opts);
        file._initStylePlacedholder || parsePackStyle(file, context, opts);
    }
971938
public function append()
    {
        $script = $this->parseArgs(func_get_args());
        if ($script !== false && !in_array($script, $this->members)) array_push($this->members, $script);
    }
1079408
def copy_extras(config):
  """"""
  outdir = config['outdir']
  for dst, src in config['extras'].items():
    dst_path = os.path.join(outdir, dst)
    dst_dir = os.path.dirname(dst_path)
    if not os.path.isdir(dst_dir):
      os.makedirs(dst_dir)
    shutil.copy(src, dst_path)
169128
function appendStyle(code) {
        var dom = document.createElement('style');
        dom.innerHTML = code;
        head.appendChild(dom);
    }
580284
function ()
		{
			for (c in this.c)
			{
				if (this.c[c].build && this.c[c].build.extend && this.c[c].build.extend.indexOf('wnScript')!=-1)
				{
					this.prepareScript(c);
				}
			}
		}
764359
function copyIfNotExists (src, dst) {
    if (!fs.existsSync(dst) && src) {
        fs.copySync(src, dst);
    }
}
1256212
def add_JSscript(self, js_script, js_loc):
        
        if js_loc == 'head':
            self.jscript_head_flag = True
            if self.jscript_head:
                self.jscript_head = self.jscript_head + '\n' +  js_script
            else:
                self.jscript_head = js_script
        elif js_loc == 'end':
            self.jscript_end_flag = True
            if self.jscript_end:
                self.jscript_end = self.jscript_end + '\n' +  js_script
            else:
                self.jscript_end = js_script
        else:
            raise OptionTypeError("Not An Accepted script location: %s, either 'head' or 'end'" 
                                % js_loc)
186884
def append(self, mode):
        
        _logger().log(5, 'adding mode %r', mode.name)
        self._modes[mode.name] = mode
        mode.on_install(self.editor)
        return mode