Skip to content

Instantly share code, notes, and snippets.

View corbanbrook's full-sized avatar

Corban Riley corbanbrook

  • Horizon Blockchain Games
  • Toronto, Canada
  • X @corban
View GitHub Profile
Lately I've been thinking about better ways of namespacing directives and more specifically
the need to create global directives for one-off pieces of code that are specific to the
context of given controller. Often the only reason I create a directive is because I need
a link function to do some DOM manipulation. Here is my dirty little experiment:
app.directive 'pxLink', ->
link: ($scope, $el, $attrs) -> $scope[$attrs.pxLink]?($el, $attrs)
<div class="thing" px-link="myLinker"></div>
# Gulp and plugins
gulp = require('gulp')
gutil = require('gulp-util')
plugins = require("gulp-load-plugins")(scope: ["dependencies", "devDependencies"])
# Utilities
grunt = require('grunt')
glob = require('glob')
path = require('path')
def update_all
updated_styles = []
params[:styles].each do |style_params|
style = styles.find(style_params[:id])
update_resource_attributes!(style, style_params)
style.save!
updated_styles << style
end
respond_with(updated_styles)
end
/* custom extends start */
.view-header .button {
/* $header-icon-color */
color: $header-icon-color;
}
.view-header {
background-color: $header-background-color;
border-bottom: $header-bottom-border-size solid $header-accent-color;
}
// Netratings SiteCensus v53.js
// COPYRIGHT 2007 Nielsen//Netratings
function random()
{
random.seed = (random.seed*random.a + random.c) % random.m;
return random.seed / random.m;
}
random.m=714025;
random.a=4096;
(function() {
/**
MSGAPP Tracking Script
Modified for use within the Softchoice Pressly App
**/
class SoftchoiceAddAnalyticsScript < PresslyMigrator::Seed
def self.up
account = Account.where(uid: 'softchoice').first
if account && (site = account.sites.where(uid: 'link').first)
# install analytics script for both apps
site.apps.each do |app|
app.scripts.create!(name: 'msgapp',
type: 'js',
source: load_source,
class SoftchoiceAddAnalyticsScript < PresslyMigrator::Seed
def self.up
account = Account.where(uid: 'softchoice').first
file_path = PresslyDashboard.root.join('db/scripts/softchoice/msgapp.js')
source = File.read(file_path)
if account && (site = account.sites.where(uid: 'link').first)
# install analytics script for both apps
site.apps.each do |app|
class SoftchoiceAddAnalyticsScript < PresslyMigrator::Seed
def self.up
account = Account.where(uid: 'softchoice').first
file_path = PresslyDashboard.root.join('db/scripts/softchoice/msgapp.js')
source = File.read(file_path)
if account && (site = account.sites.where(uid: 'link').first)
# install analytics script for both apps
site.apps.each do |app|
var navItems = _.chain(Pressly.Manifest.sections).select(function(section) {
// Select all the sections which are not shallow and..
return !section.shallow && section.assets.length > 0;
}).collect(function(section) {
// Collect assets from these section which includes..
return _(section.assets).detect(function(asset) {
// The first article asset it finds that ..
return asset.type === "article" && asset.children && _(asset.children).any(function(child) {
// Has a a child asset with type of image
return child.type === "image";