Load user scripts and styles to augment your Sketchpad development
978020
public function assets(SketchpadConfig $config)
	{
		$assets = $config->settings->get('paths.assets');
		$views = $config->settings->get('paths.views');
		md('sketchpad::help/setup/assets', compact('assets', 'views'));
	}
861070
function _draw_table_or_something(resp, manager){

	// Wipe interface.
	jQuery('#' + interface_id).empty();

	// Vary by what we got.
	if( ! resp.success() || resp.total_documents() === 0 ){
	    jQuery('#' + interface_id).append('<em>No results given your input and search fields. Please refine and try again.</em>');
	    last_response = null;
	}else{
	    last_response = resp;

	    // Render the buttons.
	    //console.log('user_buttons: ', user_buttons);
	    if( user_buttons && user_buttons.length && user_buttons.length > 0 ){

		// Ensure we have somewhere to put our buttons. If not
		// supplied with an injection id, make our own and use
		// it.
		var insert_div_id = user_buttons_div_id;
		if( ! user_buttons_div_id ){

		    // Generate new dic and add it to the display.
		    var ubt_attrs = {
			'generate_id': true
		    };
		    var ubt = new bbop.html.tag('div', ubt_attrs);
		    jQuery('#' + interface_id).append(ubt.to_string());
		    
		    // Ensure the id.
		    insert_div_id = ubt.get_id();
		}

		// Add all of the defined buttons after the spacing.
		_draw_user_buttons(user_buttons, insert_div_id);
	    }

	    // Display results.
	    var bwd = bbop.widget.display;
	    results_table =
		new bwd.results_table_by_class_conf_b3(conf_class, resp, linker,
						       handler, interface_id,
						       selectable_p,
						       select_column_id,
						       select_item_name);
	}
    }
656859
function () {
    // render stylesheets
    var precss = fs.readFileSync(__dirname + '/themes/default/styl/default.styl', 'utf8');
    stylus.render(precss, { filename: 'default.css' }, function(err, css){
      if (err) {
        throw err;
      }

      this.styles = css;
    }.bind(this));

    // collect client js (to be inined later)
    this.js = fs.readFileSync(__dirname + '/themes/default/js/default.js', 'utf8');

    // register handlebars helpers
    Handlebars.registerHelper('roundNumber', function (number) {
      return Math.round(number * Math.pow(10, 2)) / Math.pow(10, 2);
    });

    // collect & compile templates
    this.templates = {};
    this.templates.test = Handlebars.compile(fs.readFileSync(__dirname + '/themes/default/hbs/test.hbs', 'utf8'));
    this.templates.wrapper = Handlebars.compile(fs.readFileSync(__dirname + '/themes/default/hbs/wrapper.hbs', 'utf8'));
    this.templates.testresult = Handlebars.compile(fs.readFileSync(__dirname + '/themes/default/hbs/tests.hbs', 'utf8'));
    this.templates.banner = Handlebars.compile(fs.readFileSync(__dirname + '/themes/default/hbs/banner.hbs', 'utf8'));
    this.templates.detail = Handlebars.compile(fs.readFileSync(__dirname + '/themes/default/hbs/detail.hbs', 'utf8'));

    return this;
  }
60486
function includeJscad(fn) {
// include the requested script via MemFs if possible
  if (typeof(gMemFs) == 'object') {
    for (var i = 0; i < gMemFs.length; i++) {
      if (gMemFs[i].name == fn) {
        eval(gMemFs[i].source);
        return;
      }
    }
  }
// include the requested script via importScripts
  var url = self.relpath+fn;
  if (fn.match(/^(https:|http:)/i)) {
    url = fn;
  }
  importScripts(url);
  return true;
}
533675
def entrypoint_script(*lines):
    ''
    lines = list(lines)
    if lines and not lines[0].startswith('#!'):
        lines.insert(0, '#!/bin/sh')
    return eval([['entrypoint', '/entrypoint'],
                 ['write-script', '/entrypoint'] + lines])
1270076
function ready () {

    var hash = location.hash.substr( 1 );
    if(hash !=='') demoName = hash;
    editor.load('demos/' + demoName + '.js');

}
1120733
def loadInputPatterns(self, filename, cols = None, everyNrows = 1,
                          delim = ' ', checkEven = 1):
        
        self.loadInputPatternsFromFile(filename, cols, everyNrows,
                                       delim, checkEven)
34518
def run_sketch(self):
        
        Sketch.instance = self
        self.init()
        frame = self.create_frame()
        if frame:
            frame.add(self)
            frame.pack()
            frame.visible = 1
176721
def load(self, f):
        """"""
        SUPPORTED_COLOR_TYPES = (COLOR_TYPE_TRUECOLOR, COLOR_TYPE_TRUECOLOR_WITH_ALPHA)
        SAMPLES_PER_PIXEL = { COLOR_TYPE_TRUECOLOR: 3,
                              COLOR_TYPE_TRUECOLOR_WITH_ALPHA: 4 }

        assert f.read(8) == SIGNATURE

        chunks = iter(self.chunks(f))
        header = next(chunks)
        assert header[0] == b'IHDR'

        (width, height, bit_depth, color_type, compression,
         filter_type, interlace) = struct.unpack(b"!2I5B", header[1])

        if bit_depth != 8:
            raise ValueError('Unsupported PNG format (bit depth={}; must be 8)'.format(bit_depth))
        if compression != 0:
            raise ValueError('Unsupported PNG format (compression={}; must be 0)'.format(compression))
        if filter_type != 0:
            raise ValueError('Unsupported PNG format (filter_type={}; must be 0)'.format(filter_type))
        if interlace != 0:
            raise ValueError('Unsupported PNG format (interlace={}; must be 0)'.format(interlace))
        if color_type not in SUPPORTED_COLOR_TYPES:
            raise ValueError('Unsupported PNG format (color_type={}; must one of {})'.format(SUPPORTED_COLOR_TYPES))

        self.width = width
        self.height = height
        self.canvas = bytearray(self.bgcolor * width * height)
        bytes_per_pixel = SAMPLES_PER_PIXEL[color_type]
        bytes_per_row = bytes_per_pixel * width
        bytes_per_rgba_row = SAMPLES_PER_PIXEL[COLOR_TYPE_TRUECOLOR_WITH_ALPHA] * width
        bytes_per_scanline = bytes_per_row + 1

        # Python 2 requires the encode for struct.unpack
        scanline_fmt = ('!%dB' % bytes_per_scanline).encode('ascii')

        reader = ByteReader(chunks)

        old_row = None
        cursor = 0
        for row in range(height):
            scanline = reader.read(bytes_per_scanline)
            unpacked = list(struct.unpack(scanline_fmt, scanline))
            old_row = self.defilter(unpacked[1:], old_row, unpacked[0], bpp=bytes_per_pixel)
            rgba_row = old_row if color_type == COLOR_TYPE_TRUECOLOR_WITH_ALPHA else rgb2rgba(old_row)
            self.canvas[cursor:cursor + bytes_per_rgba_row] = rgba_row
            cursor += bytes_per_rgba_row
1189589
function(url, win, attributes) {
        var o = {
            id:   Y.guid(),
            type: TYPE_JS
        };

        if (attributes) {
            Y.mix(o, attributes);
        }

        o.src = url;

        return _node("script", o, win);
    }
803312
def _load_themes(self):
        """"""
        with utils.temporary_chdir(utils.get_file_directory()):
            self._append_theme_dir("themes")
            self.tk.eval("source themes/pkgIndex.tcl")
            theme_dir = "gif" if not self.png_support else "png"
            self._append_theme_dir(theme_dir)
            self.tk.eval("source {}/pkgIndex.tcl".format(theme_dir))
        self.tk.call("package", "require", "ttk::theme::scid")
688465
def main(argv=None):
	

	print("Ontospy " + ontospy.VERSION)
	ontospy.get_or_create_home_repo()

	if argv:
		print("Argument passing not implemented yet")
		if False:
			onto = Model(argv[0])
			for x in onto.get_classes():
				print(x)
			onto.buildPythonClasses()
			s = Sketch()

	else:

		intro = """Good morning. Ready to Turtle away. Type docs() for help."""
		# idea: every time provide a different ontology maxim!

		def docs():
			print("\n".join([x.strip() for x in Sketch.__doc__.splitlines()]))

		default_sketch = Sketch()

		def add(text=""):
			default_sketch.add(text)
		def show(aformat=None):
			if aformat:
				default_sketch.show(aformat)
			else:
				default_sketch.show()
		def bind(prefixTuple):
			default_sketch.bind(prefixTuple)
		def clear():
			default_sketch.clear()
		def omnigraffle():
			default_sketch.omnigraffle()


		try:
			# note: this requires IPython 0.11 or above
			import IPython
			IPython.embed(banner1=intro)
		except:
			import code
			code.interact(banner=intro, local=dict(globals(), **locals()))
	# finally
	sys.exit(0)
1152778
def load_script(browser, url):
    """"""
    if browser.current_url.startswith('file:'):
        url = 'https:' + url
    browser.execute_script("""
    var script_tag = document.createElement("script");
    script_tag.setAttribute("type", "text/javascript");
    script_tag.setAttribute("src", arguments[0]);
    document.getElementsByTagName("head")[0].appendChild(script_tag);
    """, url)

    sleep(1)
75596
def setup_ui(self, ):
        
        plus_icon = get_icon('glyphicons_433_plus_bright.png', asicon=True)
        self.add_tb.setIcon(plus_icon)

        self.shot_browser = ListBrowser(4, parent=self, headers=["Project", "Sequence", "Shot", "Type"])
        self.asset_browser = ListBrowser(4, parent=self, headers=["Project", "Assettype", "Asset", "Type"])

        self.shotmodel = self.create_shot_model()
        self.assetmodel = self.create_asset_model()

        self.shot_browser.set_model(self.shotmodel)
        self.asset_browser.set_model(self.assetmodel)

        self.shot_vbox.addWidget(self.shot_browser)
        self.asset_vbox.addWidget(self.asset_browser)
641641
def update_style(self, mapping):
        """"""
        default = {
            "presentation:background-visible": "true",
            "presentation:background-objects-visible": "true",
            "draw:fill": "solid",
            "draw:fill-color": "#772953",
            "draw:fill-image-width": "0cm",
            "draw:fill-image-height": "0cm",
            "presentation:display-footer": "true",
            "presentation:display-page-number": "false",
            "presentation:display-date-time": "true",
        }
        default.update(mapping)
        style = PageStyle(**default)
        node = style.style_node()
        # add style to automatic-style
        self.preso._auto_styles.append(node)
        # update page style-name
        # found in ._page
        self._page.set(ns("draw", "style-name"), node.attrib[ns("style", "name")])
1136334
function paperLoadedInit() {
  console.log('Paper ready!');

  // Set center adjusters based on size of canvas
  $('#hcenter').attr({
    value: 0,
    min: -(robopaint.canvas.width / 2),
    max: robopaint.canvas.width / 2
  });

  $('#vcenter').attr({
    value: 0,
    min: -(robopaint.canvas.height / 2),
    max: robopaint.canvas.height / 2
  });

  $(window).resize();

  // Use mode settings management on all "managed" class items. This
  // saves/loads settings from/into the elements on change/init.
  mode.settings.$manage('.managed');

  // With Paper ready, send a single up to fill values for buffer & pen.
  mode.run('up');
}
343847
function buildScriptsAndStyleFiles(outputPath) {
	const stylesRegex = /<style>|<\/style>/gi,
		scriptsRegex = /<script type="text\/javascript">|<\/script>/gi;

	// creates the report directory if it doesn't exist
	if (!fs.existsSync(outputPath)) {
		fs.mkdirSync(outputPath);
	}

	// create the styles.css and main.js files
	writeFile(`${outputPath}styles.css`, styles(), stylesRegex);
	writeFile(`${outputPath}main.js`, scripts(), scriptsRegex);
}