Exemplo n.º 1
0
function getMethodName(method, path) {
  var name = path.split('/');
  if (!name.length) throw new Error('Bad Route');
  if (name.length === 1) return method + capitalize(name[0]);

  for (var x in name) {
    name[x] = name[x].replace(/\W+/g, '');
    name[x] = capitalize(name[x]);
  }
  return method + name.join('');
}
Exemplo n.º 2
0
	// Is the tree identical to matrix
	isTreeMatrix(curr, type, options) {
		const differences = toolbox.compareLists(fss.scandir(`${paths.directory.root}${curr}`, type, options), fss.scandir(`${paths.workflow.matrix}${curr}`, type, options));

		return {
			success:     differences.pass,
			message:     `${Reporter.theme.title(curr)}: ${capitalize(type)}s list must be identical to matrix`,
			differences: differences
		};
	}
Exemplo n.º 3
0
  prompting: function () {
    var done = this.async();

    // Have Yeoman greet the user.
    this.log(yosay(
      'Welcome to the ' + chalk.red('Koto') + ' generator!'
    ));

    var config = gitConfig.sync();

    var prompts = [{
      type: 'input',
      name: 'user',
      message: 'What is your github username/organization?'
    }, {
      type: 'input',
      name: 'repo',
      message: 'What is your repo/projects name?',
      default: 'koto.' + capitalize(camelcase(this.appname))
    }, {
      type: 'input',
      name: 'description',
      message: 'What is a description of this project? (eg. A nice koto chart.)'
    }, {
      type: 'input',
      name: 'author',
      message: 'Who is the author of this project?',
      default: (config && config.user && config.user.name) ? config.user.name + ' <' + config.user.email + '>' : ''
    }, {
      type: 'input',
      name: 'global',
      message: 'What would you like to attach to the koto global (in browsers)? ex. koto.[name]',
      default: capitalize(camelcase(this.appname))
    }];

    this.prompt(prompts, function (props) {
      this.user = props.user;
      this.repo = props.repo;
      this.description = props.description;
      this.author = props.author;
      this.global = props.global;
      done();
    }.bind(this));
  },
Exemplo n.º 4
0
 var attributes = toArray(mapValues(resource.model.attributes, function(value, key) {
   var inputElementAttributes = value.inputElementAttributes || {}
   if (!inputElementAttributes.type)
     inputElementAttributes.type = 'text'
   return {
     id: uuid(),
     lowercase: key.toLowerCase(),
     capitalized: caps(key),
     type: value.type,
     remove: value.remove || false,
     model: value.model ? {
       title: find(resources, { name: value.model }).view.titleField,
       name: value.model,
       capitalized: caps(value.model)
     } : false,
     inputElement: value.inputElement || 'input',
     inputIsNotVoidElement: !contains(voidElements, value.inputElement || 'input'),
     inputElementAttributes: inputElementAttributes
   }
 }));
Exemplo n.º 5
0
 const amenitiesToRender = amenities.map((amenity, index) => {
   if (amenity === 'minimarket') {
     amenity = 'minimarked';
   }
   if (amenity === 'childrenpool') {
     amenity = 'børnepool';
   }
   return (
     <div key={index} className='factPair'>
       <div className='fact'>{capitalize(amenity)}</div>
       <div className='value'>Ja</div>
     </div>
   );
 });
Exemplo n.º 6
0
Arquivo: index.js Projeto: daisywr/tmp
function parse(text, regexp, mentionRegexp, {actions, issuePrefixes, hosts}) {
	let parsed;
	const results = {
		actions: Object.keys(actions).reduce(
			(result, key) => (actions[key].length > 0 ? Object.assign(result, {[key]: []}) : result),
			{}
		),
		refs: [],
		mentions: [],
	};
	let noCodeBlock = inverse(inverse(text.replace(FENCE_BLOCK_REGEXP, '')).replace(CODE_BLOCK_REGEXP, ''));

	while (regexp.test(noCodeBlock)) {
		noCodeBlock = noCodeBlock.replace(HTML_CODE_BLOCK_REGEXP, '');
	}

	while ((parsed = regexp.exec(noCodeBlock)) !== null) {
		let [raw, action, slug, prefix, issue, mentions] = parsed;
		prefix =
			prefix && issuePrefixes.some(issuePrefix => issuePrefix.toUpperCase() === prefix.toUpperCase())
				? prefix
				: undefined;
		raw = parsed[0].substring(
			parsed[0].indexOf(
				parsed[1] || hosts.find(host => parsed[0].toUpperCase().includes(host.toUpperCase())) || parsed[2] || parsed[3]
			)
		);
		action = capitalize(parsed[1]);

		const actionTypes = Object.keys(actions).filter(key => includesIgnoreCase(actions[key], action));

		if (actionTypes.length > 0) {
			for (const actionType of actionTypes) {
				results.actions[actionType].push({raw, action, slug, prefix, issue});
			}
		} else if (issue) {
			results.refs.push({raw, slug, prefix, issue});
		} else if (mentions) {
			let parsedMention;
			while ((parsedMention = mentionRegexp.exec(mentions)) !== null) {
				const [rawMention, prefixMention, user] = parsedMention;

				results.mentions.push({raw: rawMention.trim(), prefix: prefixMention, user});
			}
		}
	}
	return results;
}
Exemplo n.º 7
0
var formatOutput = function (str) {
  return capitalize(kebabcase(str));
};
Exemplo n.º 8
0
    view : function(ctrl) {
        var current = m.route(),
            content = ctrl.results || ctrl.content || [],
            now     = Date.now(),
            locked  = config.locked;

        if(!m.route.param("id")) {
            document.title = capitalize(ctrl.schema.name);
        }

        return m("div", { class : css[ctrl.hidden ? "hide" : "nav"] },
            m(".head", { class : css.filter },
                m("input", {
                    class       : css.text,
                    placeholder : "Search...",
                    oninput     : m.withAttr("value", ctrl.filter)
                }),
                m("div", {
                        class   : ctrl.hidden ? css.show : css.hide,
                        onclick : ctrl.hide
                    },
                    m("span", ctrl.hidden ? "show" : "hide")
                )
            ),
            m("div", { class : css.body },
                m("ul", { class : css.list },
                    content
                    .sort(function(a, b) {
                        var aTime = a.published_at || a.published || a.updated_at,
                            bTime = b.published_at || b.published || b.updated_at;

                        return bTime - aTime;
                    })
                    .map(function(data) {
                        var url      = "/content/" + ctrl.schema.key + "/" + data.key,
                            cssClass = css.item,
                            status;

                        if(data.published_at && current.indexOf(url) === 0) {
                            cssClass = css.activePublished;
                        } else if(current.indexOf(url) === 0) {
                            cssClass = css.active;
                        } else if(data.published_at) {
                            cssClass = css.published_at;
                        }

                        if(data.published_at > now) {
                            status = "scheduled: " + data.moments.published.format("L");
                        } else if(data.published_at < now) {
                            status = "published: " + data.moments.published.format("L");
                        } else {
                            status = "updated: " + data.moments.updated.format("L");
                        }

                        return m("li", { class : cssClass },
                            m("a", {
                                    class  : css.anchor,
                                    href   : prefix("/content/" + ctrl.schema.key + "/" + data.key),
                                    config : m.route
                                },
                                m("h3", { class : css.heading }, data.name),
                                m("p", { class : css.date },
                                    status
                                )
                            ),
                            m("div", { class : css.actions },
                                ctrl.schema.preview ?
                                    m("a", {
                                            class  : css.preview,
                                            title  : "Preview",
                                            href   : ctrl.schema.preview + data.key,
                                            target : "_blank"
                                        },
                                        m("svg", { class : css.icon },
                                            m("use", { href : icons + "#preview" })
                                        )
                                    ) :
                                    null,
                                m("button", {
                                        // Attrs
                                        class    : css.remove,
                                        title    : "Remove",
                                        disabled : locked || null,
                                        
                                        // Events
                                        onclick : ctrl.remove.bind(ctrl, data)
                                    },
                                    m("svg", { class : css.icon },
                                        m("use", { href : icons + "#remove" })
                                    )
                                )
                            )
                        );
                    })
                )
            ),
            m("div", { class : css.metas },
                m("button", {
                        onclick  : ctrl.add,
                        class    : css.add,
                        disabled : locked || null
                    },
                    "Add " + ctrl.schema.name
                )
            )
        );
    }
Exemplo n.º 9
0
export function view(ctrl, options) {
    var status  = "draft",
        publish = options.data.published_at || options.data.published,
        future  = isFuture(ctrl.start.date + " " + ctrl.start.time),
        locked  = config.locked;

    if(isFuture(publish)) {
        status = "scheduled";
    } else if(isPast(publish)) {
        status = "published";
    }

    return m("div", { class : css.head },
        m("div", { class : css.main },
            m("p", { class : css[status] },
                upper(status)
            ),
            m("div", { class : css.actions },
                ctrl.saving ?
                    "SAVING..." : m("button", {
                        // Attrs
                        class    : css.save,
                        title    : "Save your changes",
                        disabled : locked || null,

                        // Events
                        onclick : ctrl.save.bind(null, options)
                    },
                    m("svg", { class : css.icon },
                        m("use", { href : icons + "#save" })
                    ),
                    "Save"
                )
            ),
            m("div", { class : css.publishing },
                m("button", {
                        // Attrs
                        class : css.schedule,
                        title : "Schedule a publish",

                        // Events
                        onclick : ctrl.toggle.bind(null, undefined)
                    },
                    m("svg", { class : css.onlyIcon },
                        m("use", { href : icons + "#schedule" })
                    )
                ),
                m("button", {
                        // Attrs
                        class    : css.publish,
                        title    : future ? "Schedule publish" : "Publish now",
                        disabled : locked || null,

                        // Events
                        onclick : ctrl.publish
                    },
                    m("svg", { class : css.icon },
                        m("use", { href : icons + (future ? "#schedule" : "#publish") })
                    ),
                    future ? "Schedule" : "Publish"
                ),
                status === "draft" ?
                    null :
                    m("button", {
                            // Attrs
                            class    : css.unpublish,
                            title    : "Unpublish immediately",
                            disabled : locked || null,

                            // Events
                            onclick : ctrl.unpublish
                        },
                        m("svg", { class : css.icon },
                            m("use", { href : icons + "#remove" })
                        ),
                        "Unpublish"
                    )
            )
        ),
        ctrl.schedule ? m("div", { class : css.details },
            m("div", { class : css.start },
                m("p",
                    m("label", { for : "published_at_date" }, "Publish at")
                ),
                m("p",
                    m("input", {
                        class : css.date,
                        type  : "date",
                        id    : "published_at_date",
                        value : ctrl.start.date,

                        // Events
                        oninput : m.withAttr("value", ctrl.update.bind(ctrl, "start", "date"))
                    })
                ),
                m("p",
                    m("input", {
                        class : css.date,
                        type  : "time",
                        id    : "published_at_time",
                        value : ctrl.start.time,

                        // Events
                        oninput : m.withAttr("value", ctrl.update.bind(ctrl, "start", "time"))
                    })
                )
            ),
            m("div", { class : css.end },
                m("p",
                    m("label", { for : "unpublished_at_date" }, "Until (optional)")
                ),
                m("p",
                    m("input", {
                        class : css.date,
                        type  : "date",
                        id    : "unpublished_at_date",
                        value : ctrl.end.date,

                        // Events
                        oninput : m.withAttr("value", ctrl.update.bind(ctrl, "end", "date"))
                    })
                ),
                m("p",
                    m("input", {
                        class : css.date,
                        type  : "time",
                        id    : "unpublished_at_time",
                        value : ctrl.end.time,

                        // Events
                        oninput : m.withAttr("value", ctrl.update.bind(ctrl, "end", "time"))
                    })
                )
            )
        ) : null
    );
}
Exemplo n.º 10
0
		arr = arr.map((word) => isAlpha(word) ? capitalize(word) : word)
Exemplo n.º 11
0
 /**
  * Capitalizes the first letter in the string
  * @param {String} str
  * @return {String}
  * @private
  */
 _capitalize(str) {
     return capitalize(str[0]) + str.slice(1);
 }
Exemplo n.º 12
0
export function view(ctrl) {
    if(!ctrl.schema) {
        return m.component(layout);
    }
    
    return m.component(layout, {
        title   : "Edit - " + capitalize(ctrl.schema.name),
        content : m("div", { class : layout.css.content },
            ctrl.error ?
                m("p", { class : css.error }, ctrl.error) :
                null,

            m("div", { class : css.meta },
                m("h3", "Metadata"),
                m("div", { class : css.sections },
                    m("div", { class : css.section },
                        m("label", { class : css.label, for : "preview" }, "Preview URL Base"),
                        m("input", {
                            // Attrs
                            id    : "preview",
                            class : css[ctrl.preview.valid ? "preview" : "previewError"],
                            type  : "url",
                            value : ctrl.preview.value || "",
                            
                            // Events
                            oninput : ctrl.previewChanged,
                            
                            // Config Fn
                            config : function(el, init) {
                                if(init) {
                                    return;
                                }

                                ctrl.preview.valid = el.validity.valid;
                            }
                        }),
                        m("p", { class : css.note },
                            ctrl.preview.value ?
                                ctrl.preview.value + "-0IhUBgUFfhyLQ2m6s5x" :
                                null
                        )
                    ),
                    m("div", { class : css.section },
                        m("label", { class : css.label },
                            m("input", {
                                // Attrs
                                css     : css.slug,
                                type    : "checkbox",
                                checked : ctrl.schema.slug,
                                
                                // Events
                                onchange : m.withAttr("checked", ctrl.slugChanged)
                            }),
                            " Generate slugs for entries?"
                        )
                    )
                )
            ),
            m("div", { class : css.contents },
                m("div", { class : css.editor },
                    m("h3", "Field Definitions"),
                    m.component(editor, {
                        ref    : ctrl.ref,
                        worker : ctrl.worker,
                        source : ctrl.schema.source || "{\n\n}"
                    })
                ),

                m("div", { class : css.fields },
                    m("h3", "Preview"),
                    m.component(children, {
                        fields : ctrl.schema.fields,
                        data   : ctrl.data,
                        path   : [],
                        state  : ctrl.data,
                        update : update.bind(null, ctrl.data)
                    })
                )
            )
        )
    });
}
Exemplo n.º 13
0
 ExtJSComponent.prototype._capitalize = function _capitalize(str) {
     return capitalize(str[0]) + str.slice(1);
 };
Exemplo n.º 14
0
function eachResource(resource) {
  if (!resource.view) return

  var clientViewPath = __dirname + '/../client/plugins/' + resource.name + '/'
    , templatePath = __dirname + '/templates/view/'
    , checksumPath = __dirname + '/../client/plugins/.' + resource.name + '.md5'
    , oldChecksum, newChecksum;

  var voidElements = ['area', 'base', 'br', 'col', 'embed', 'hr', 'img', 'input', 'keygen', 'link', 'meta', 'param', 'source', 'track', 'wbr'];

  var attributes = toArray(mapValues(resource.model.attributes, function(value, key) {
    var inputElementAttributes = value.inputElementAttributes || {}
    if (!inputElementAttributes.type)
      inputElementAttributes.type = 'text'
    return {
      id: uuid(),
      lowercase: key.toLowerCase(),
      capitalized: caps(key),
      type: value.type,
      remove: value.remove || false,
      model: value.model ? {
        title: find(resources, { name: value.model }).view.titleField,
        name: value.model,
        capitalized: caps(value.model)
      } : false,
      inputElement: value.inputElement || 'input',
      inputIsNotVoidElement: !contains(voidElements, value.inputElement || 'input'),
      inputElementAttributes: inputElementAttributes
    }
  }));

  var viewConfig = {
    name: resource.name,
    nameCapitalized: caps(resource.name),
    nameAllCaps: resource.name.toUpperCase(),
    titleField: resource.view.titleField,
    teaserFields: returnAttributes(resource.view.teaserFields),
    detailFields: returnAttributes(resource.view.detailFields),
    attributes: attributes
  };

  function returnAttributes(fields) {
    var toReturn = [];
    for (var x in fields)
      toReturn.push(find(attributes, { lowercase: fields[x] }));
    return toReturn;
  }

  async.waterfall([

    // Read checksum from existing view plugin
    function(cb) {
      fs.readFile(checksumPath, { encoding: 'utf8' }, function (err, checksum) {
        return cb(null, checksum);
      })
    },

    // Assign to oldChecksum and read files to create newChecksum
    function(md5, cb) {
      oldChecksum = md5 || null;
      if (isNull(oldChecksum)) return cb(null, null)
      dirsum.digest(clientViewPath, 'md5', cb);
    },

    // Assign newChecksum and compare, if the same delete plugin folder
    function(hashes, cb) {
      if (isNull(oldChecksum)) return cb(null)
      newChecksum = hashes.hash;
      if (oldChecksum !== newChecksum)
        return cb(new Error('Checksum mismatch.'))
      deleteFolder(clientViewPath);
      cb(null);
    },

    // Check if plugin folder exists
    function(cb) {
      fs.lstat(clientViewPath, function(err, folderStats) {
        if (err) return cb(null, false)
        cb(null, folderStats.isDirectory());
      })
    },

    // If folder doesn't exists create it
    function(exists, cb) {
      if (exists) return cb(null)
      fs.mkdir(clientViewPath, cb)
    },

    // List files in template directory
    function(cb) {
      fs.readdir(templatePath, cb);
    },

    // Write template files
    function(files, cb) {
      async.each(files, function(file, cb) {
        fs.readFile(templatePath + file, { encoding: 'utf8' }, function(err, template) {
          if (err) return cb(err);
          hbTemplate = Handlebars.compile(template);
          fs.writeFile(clientViewPath + file.replace('.hbs', ''), hbTemplate(viewConfig), cb);
        })
      }, cb);
    },

    // Get new checksum
    function(cb) {
      dirsum.digest(clientViewPath, 'md5', cb);
    },

    // Write new checksum
    function(hashes, cb) {
      fs.writeFile(checksumPath, hashes.hash, cb);
    }
  ], function(err){
    if (err) console.error(err);
  })

}