Ejemplo n.º 1
0
function generatePlaylist (doc) {
  var songs = [];

  var name;
  for (name in doc.songs) {
    songs.push(format(templates['song.html'], {
      title: name,
      url: doc.songs[name]
    }));
  }

  return format(templates['playlist.html'], {
    songs: songs.join('\n')
  });
}
Ejemplo n.º 2
0
  return function(element, newValue, vars){
    if ( arguments.length > 1 ) {
      element.textContent = arguments.length > 2 ? format(newValue, vars) : newValue;
      return chain;
    }

    return element.textContent;
  };
Ejemplo n.º 3
0
  return function(element, newValue, vars){
    if (arguments.length > 1) {
      element.innerHTML = arguments.length > 2 ? format(newValue, vars) : newValue;
      return chain;
    }

    return element.innerHTML;
  };
Ejemplo n.º 4
0
function render(){
  if ( ! current.exercise() ) return '';

  var circles = '';

  var i = -1, len = onlyExercises.length;
  while ( ++i < len ) {
    console.log('==>', i, onlyExercises[i], current.exercise());
    circles += format(templates['circle.html'], {
      done: current.exercise().index > onlyExercises[i].index ? 'done' : ''
    });
  }

  return format(templates['progress.html'], {
    title: current.exercise().title,
    circles: circles
  });
}
Ejemplo n.º 5
0
function writeEmbedJSON (name, dir, doc) {
  var target = path.join(dir, name, '/embed.json');
  debug('Writing %s', target);
  fs.writeFileSync(target, format(templates['embed.json'], {
    title: doc.title,
    url: doc.url || '',
    image: doc.image
  }));
}
Ejemplo n.º 6
0
function writeEntry (name, dir, doc) {
  var target = path.join(dir, name,  '/_entry.js');
  var js = format(templates['entry.js'], {
    options: JSON.stringify({ soundcloud: doc.soundcloud })
  });

  debug('Writing %s temporarily.', target);
  fs.writeFileSync(target, js);

  return target;
}
Ejemplo n.º 7
0
function bg (parent, imageUrl, options) {
  if (typeof parent == 'string') parent = select(parent);

  parent.style.background = format(template, {
    color: options && options.color || '#111',
    url: imageUrl,
    repeat: options && options.repeat || 'no-repeat',
    position: options && options.position || 'center center'
  });

  parent.style.backgroundSize = options && options.size || 'cover';
}
Ejemplo n.º 8
0
function renderModule(module){
  if( ~ renderModule.memo.indexOf(module.id) || ~ options.ignore.indexOf(module.filename) ) return undefined;

  renderModule.memo.push(module.id);

  debug('Rendering %s at %s', module.name, module.filename);

  if(module.isJSON) {
    return renderJSONModule(module);
  }

  return format(templates.module, { id: module.id, content: module.content, requires: JSON.stringify(mapOf(module)) });
}
Ejemplo n.º 9
0
function writeHTML (name, dir, doc) {
  var html = format(templates['index.html'], {
    name: name,
    title: doc.title,
    image: doc.image,
    header: templates['header.html'],
    playlist: generatePlaylist(doc),
    url: doc.url || ''
  });

  var target = path.join(dir, name, '/index.html');

  debug('Writing %s', target);
  fs.writeFileSync(target, html);
}
Ejemplo n.º 10
0
function render(module){

  options.require.forEach(function(uri){
    module.requires.push(uri);
  });

  module.init();

  return format(templates.wrapper, {
    entry                : module.id,
    map                  : renderModules(module),
    require              : renderRequire,
    'global-require'     : options.global() ? renderGlobalRequire() : '',
    'native-require'     : options.native() ? ', require' : '',
    'native-require-def' : options.native() ? 'require.nt = arguments[1];' : ''
  });
}
Ejemplo n.º 11
0
function url (area, category, pickupDay) {
  return format(urlPattern, area, category, pickupDay);
}
Ejemplo n.º 12
0
function renderJSONModule(module){
  return format(templates['json-module'], { id: module.id, content: module.content });
}
Ejemplo n.º 13
0
function renderGlobalRequire(){
  return format(templates['global-require'], { 'if-not-found': renderIfNotFound });
}
Ejemplo n.º 14
0
function renderRequire(){
  return format(templates.require, { 'if-not-found': renderIfNotFound });
}
Ejemplo n.º 15
0
function newElement (html, vars) {
  if (!vars) return domify(html);

  return domify(format(html, vars));
}
Ejemplo n.º 16
0
 html = response.result.map(function (podcast) {
   return format('<li data-url="{0}"><span>{1}</span></li>',
                 podcast.source, prettyDate(podcast.ts));
 }).join('\n');
Ejemplo n.º 17
0
function render(){
  return format(template, {
    'state-class': val() ? 'on' : 'off'
  });
}
Ejemplo n.º 18
0
function prettyDate (ts) {
  return format('{day}/{month}/{year}', padDate(new Date(ts)));
}