示例#1
0
gulp.task('favicons', ['build-html'], function (done) {
  favicons({
    files: {
      src: 'src/img/leopard.png',
      dest: 'dist',
      html: './dist/index.html'
    },
    icons: {
      android: true,
      apple: true,
      appleStartup: false,
      coast: false,
      favicons: true,
      firefox: false,
      opengraph: true,
      windows: false,
      yandex: false
    },
    settings: {
      background: '#cccccc',
      appName: 'Menagerie',
      appDescription: 'An animal sounds game for young children',
      developer: 'Euan Goddard',
      index: 'index.html',
      url: 'https://menagerie.euans.space'
    }
  }, done);
});
示例#2
0
文件: index.js 项目: gontko/portfolio
            findInfo(file.path, function (error, info) {

                var options = mergeDefaults(params || {}, {
                    files: {
                        src: info ? (info.favicon ? path.join(path.dirname(file.path), info.favicon) : null) : null,
                        dest: params.dest,
                        html: file.path,
                        iconsPath: null,
                        androidManifest: null,
                        browserConfig: null,
                        firefoxManifest: null,
                        yandexManifest: null
                    },
                    icons: {
                        android: true,
                        appleIcon: true,
                        appleStartup: true,
                        coast: true,
                        favicons: true,
                        firefox: true,
                        opengraph: true,
                        windows: true,
                        yandex: true
                    },
                    settings: {
                        appName: info.title,
                        appDescription: info.description,
                        developer: info.author,
                        developerURL: info ? (info.url ? path.join(info.url, '/') : null) : null,
                        version: 1.0,
                        background: null,
                        index: null,
                        url: info ? (info.url ? path.join(info.url, '/') : null) : null,
                        silhouette: false,
                        logging: false
                    }
                });

                if (file.isNull()) {
                    cb(null, file);
                    return;
                }

                if (file.isStream()) {
                    cb(new util.PluginError('gulp-favicons', 'Streaming not supported'));
                    return;
                }

                options.files.dest = path.join(path.dirname(file.path), options.files.dest);

                favicons(options, function (error, html) {
                    file.contents = new Buffer(_.flatten(html).join(' '));
                    return cb(error, file);
                });

            });
示例#3
0
export function generateFavicons(done) {
  return favicons(`${config.src}/favicon.png`, {
    appName: config.title,
    appDescription: config.description,
    developerName: config.author,
    developerURL: config.developerURL,
    background: 'transparent',
    path: 'images/favicon/',
    url: 'images/share.jpg',
    display: 'standalone',
    orientation: 'portrait',
    version: config.version,
    logging: config.verbose,
    online: false,
    icons: {
      android: true,
      appleIcon: true,
      appleStartup: true,
      coast: true,
      favicons: true,
      firefox: true,
      opengraph: false,
      twitter: false,
      windows: true,
      yandex: true
    }
  }, (error, response) => {
    if (error) {
      console.log(error.status);
      console.log(error.name);
      console.log(error.message);
    }

    const faviconFolder = `${config.dist}/images/favicon/`;

    if (response.images) {
      mkdirp.sync(faviconFolder);
      response.images.forEach((image) =>
        fs.writeFileSync(`${faviconFolder}${image.name}`, image.contents)
      );
    }

    if (response.files) {
      mkdirp.sync(faviconFolder);
      response.files.forEach((file) =>
        fs.writeFileSync(`${faviconFolder}${file.name}`, file.contents)
      );
    }

    if (response.html) {
      fs.writeFileSync(`${config.src}/partials/favicons.html`, response.html.join('\n'));
    }

    done();
  });
}
gulp.task('favicons', function() {
	favicons({
		// I/O
		source: 'images/favicons/source/favicon-master.png',
		dest: 'images/favicons',

		// Icon Types
		android: true,
		apple: true,
		coast: true,
		favicons: true,
		firefox: true,
		windows: true,
	});
});
    mkdirp(config.favicon.output, (error) => {
      if (!error) {
        // generate favicons
        favicons(config.favicon.entry, setup, (error, response) => {
          if (error) {
            console.log(error);
          } else {
            // output html tags
            fs.writeFile(
              config.favicon.html,
              response.html.join('\n'),
              'UTF-8',
              () => {
                console.log(`favicon ${chalk.magenta('html partial')} created`);
              }
            );

            // write favicon files
            response.files.map((file) => {
              fs.writeFile(
                config.favicon.output + file.name,
                file.contents,
                'UTF-8',
                () => {
                  console.log(`favicon ${chalk.magenta(file.name)} file created`);
                });
            });

            // write favicon images
            response.images.map((image) => {
              fs.writeFile(
                config.favicon.output + image.name,
                image.contents,
                'UTF-8',
                () => {
                  console.log(`favicon ${chalk.green(image.name)} image created`);
                }
              );
            });
          }
        });
      }
    });
示例#6
0
#!/usr/bin/env node

var favicons = require('favicons')
  , config = require('./config').favicon;

if (process.argv.length < 3)
  process.exit(1);

config.files.src = process.argv[2];

favicons(config, function (err) {
  if (err) throw err;
  process.exit(0);
});
示例#7
0
 return new Promise((resolve, reject) => {
     favicons(path2, cfgs, (err, res) => {
         if(err) return reject(err);
         resolve(res);
     });
 });
示例#8
0

        // console.log(response.files);    // Array of { name: string, contents: <string> }

        // Save "random" files
        response.files.forEach(function(v){
        	fs.writeFile("./favicon/" + v.name, v.contents, function(err){
        		if(err){
        			console.log(err);
        		}
        	});
        });


        // console.log(response.html);     // Array of strings (html elements)

		// Save HTML
		var html = "";
        response.html.forEach(function(v){
        	html += (v + '\n');
        });
        fs.writeFile("./favicon.html", html, function(err) {
		    if(err) {
		        return console.log(err);
		    }
		});
        console.log("The files was saved!");
    };

favicons(source, configuration, callback);
favicons({
    // I/O
    source: 'naginata-icon.svg',
    dest: '../public_html/icons',

    // Icon Types
    android: true,
    apple: true,
    coast: true,
    favicons: true,
    firefox: true,
    windows: true,

    // Miscellaneous
    html: 'favicons.html',
    background: '#072434',
    tileBlackWhite: false,
    manifest: false,
    trueColor: true,
    logging: true,
    callback: function () {

      minifyPng();

      // Move ico file
      fs.renameSync('../public_html/icons/favicon.ico', '../public_html/favicon.ico');

      convertJade();

      var seconds = Math.round(((new Date()).getTime() - startTime) / 100) / 10;
      console.log('Completed in ' + seconds + ' seconds. Thanks!');
    }
});
示例#10
0
        firefoxManifest: null,    // Path for an existing manifest.webapp. `string`
        yandexManifest: null      // Path for an existing yandex-browser-manifest.json. `string`
    },
    icons: {
        android: true,            // Create Android homescreen icon. `boolean`
        appleIcon: true,          // Create Apple touch icons. `boolean`
        appleStartup: true,       // Create Apple startup images. `boolean`
        coast: true,              // Create Opera Coast icon. `boolean`
        favicons: true,           // Create regular favicons. `boolean`
        firefox: true,            // Create Firefox OS icons. `boolean`
        opengraph: true,          // Create Facebook OpenGraph. `boolean`
        windows: true,            // Create Windows 8 tiles. `boolean`
        yandex: true              // Create Yandex browser icon. `boolean`
    },
    settings: {
        appName: null,            // Your application's name. `string`
        appDescription: null,     // Your application's description. `string`
        developer: null,          // Your (or your developer's) name. `string`
        developerURL: null,       // Your (or your developer's) URL. `string`
        version: 1.0,             // Your application's version number. `number`
        background: null,         // Background colour for flattened icons. `string`
        index: null,              // Path for the initial page on the site. `string`
        url: null,                // URL for your website. `string`
        silhouette: false,        // Turn the logo into a white silhouette for Windows 8. `boolean`
        logging: false            // Print logs to console? `boolean`
    },
    favicon_generation: null,     // Complete JSON overwrite for the favicon_generation object. `object`
};

favicons(config);