npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

git-imager

v1.0.8

Published

upload all base64 img data in html to github and replace src attribute to github-url

Downloads

5

Readme

NPM version npm

1. git-imager

  1. detect image tags in HTML with base64-data
  2. then upload all that images to github repository, and replace image src with generated github-url
  3. finally you can get HTML that contains img tags with github-url.
    *. ex) you can use git-imager with summenote html editor.
  • HTML img 태그안의 base64 데이터를 깃헙 레포지토리에 이미지로 올리고 생성된 url로 src 속성을 대체시켜주는 모듈.
  • summernote 써보다가 만듦.

2. example

  • source HTML will be..
<p>
<img src="data:image/jpeg;base64,/9j/4AAQSkZJRgABAQEAYABgAAD/2..........something long base64 data" 
     data-filename="testfornodejs.jpg" style="width: 100px;">
<br>
</p>
  • converted to HTML like this
<p>
  <img src="https://raw.githubusercontent.com/MinSikMoon/database_test/master/15346903140862939134887091734.jpg" 
       data-filename="testfornodejs.jpg" style="width: 100px;">
<br>
</p>

3. Usage Example Summary

var gitImager = require('git-imager');
var imager = new gitImager('[username]', '[token]', '[repository]');
 
imager.setEventHandler('makeImgUrlHtmlDone', function(convertedHtml){
    console.log(convertedHtml);
});

var sourceHtml = '<p>'  
 + '<img src="data:image/jpeg;base64,/9j/4AAQSkZJRgABAQEAYABgAAD/2wBDAAoHBwgHBgoICAgLCgoLDhgQDg0NDh0VFhEYIx8lJCIfIiEmKzcvJik0KSEiMEExNDk7Pj4+JS5ESUM8SDc9Pjv/2wBDAQoLCw4NDhwQEBw7KCIoOzs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozv/wAARCABkAGQDASIAAhEBAxEB/8QAHwAAAQUBAQEBAQEAAAAAAAAAAAECAwQFBgcICQoL/8QAtRAAAgEDAwIEAwUFBAQAAAF9AQIDAAQRBRIhMUEGE1FhByJxFDKBkaEII0KxwRVS0fAkM2JyggkKFhcYGRolJicoKSo0NTY3ODk6Q0RFRkdISUpTVFVWV1hZWmNkZWZnaGlqc3R1dnd4eXqDhIWGh4iJipKTlJWWl5iZmqKjpKWmp6ipqrKztLW2t7i5usLDxMXGx8jJytLT1NXW19jZ2uHi4+Tl5ufo6erx8vP09fb3+Pn6/8QAHwEAAwEBAQEBAQEBAQAAAAAAAAECAwQFBgcICQoL/8QAtREAAgECBAQDBAcFBAQAAQJ3AAECAxEEBSExBhJBUQdhcRMiMoEIFEKRobHBCSMzUvAVYnLRChYkNOEl8RcYGRomJygpKjU2Nzg5OkNERUZHSElKU1RVVldYWVpjZGVmZ2hpanN0dXZ3eHl6goOEhYaHiImKkpOUlZaXmJmaoqOkpaanqKmqsrO0tba3uLm6wsPExcbHyMnK0tPU1dbX2Nna4uPk5ebn6Onq8vP09fb3+Pn6/9oADAMBAAIRAxEAPwD2aiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAoqvqErQWE8iHDKhKn0NcrLqF8/ym6lwewbH8q8/F4+GFajJNtm9KhKoro7HNLXBXjS+RuWRhIrqytkkgg8V1+lanHqdsJFG2RcB09D/hUYLMYYpuNrP8y62GlTjzbovUUUV6ZyhRRRQAUUUUAFFFFABRRRQBn65IselS7iAGIXn61yn2iItkSRk/7wrtbm1t7yMR3MKTIGDbXUEZHTisiTwdpEspkaOU5JO0SYXn2HpXjZhl88TUU4vpY7cPXhTjaRzlzcRlQu5Dlh/F0pNK1GaLUY/saNLJ90oB94V0MfgnRUdGMMjleu6Q/N9cf0rZtrK2so9ltBHEvoi4zXNh8oqQmpOVrdjepi6fLypNk1LRRX0R5YUUUUAFFFFABRRRQAUUUUAFJS0UAJRS0UAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQB/9k=" data-filename="testfornodejs.jpg" style="width: 100px;">'
 + '<br>'
 + '</p>';

imager.makeImgUrlHtml(sourceHtml);

4. How to use

1. npm install

npm install --save git-imager

2. import git-imager and make git-imager object

var gitImager = require('git-imager');
var imager = new gitImager('[your github username]', '[your-github-token]', '[repository where to save images]');
 -- example
var imager = new gitImager('MinSikMoon', 'abcd577dsaadffa/aeifnvic', 'database_test');
 

3. makeImgUrlHtml(SourceHtml)

  • function
void makeImgUrlHtml(sourceHtml)
  • example 1
imager.makeImgUrlHtml(sourceHtml);
  • example 2 (in situation when you get source-html from summernote editor)
app.post("/summernoteSubmit", function(req, res){
     var sourceHtml = req.body.editordata;
     imager.makeImgUrlHtml(sourceHtml);
})     

4. setEventHandler('eventName', function(convertedHtml){})

  • git-imager emits event named 'makeImgUrlHtmlDone' when makeImgUrlHtml function finished.

  • set event handler for event named 'makeImgUrlHtmlDone' on git-imager object, so you can get converted-HTML

  • function

void setEventHandler('eventName', funtion(convertedHtml){
     //do whatever you want with convertedHtml in this callback-function.
})
  • example
imager.setEventHandler('makeImgUrlHtmlDone', function(convertedHtml){
    console.log(convertedHtml);
    //do whatever you want with convertedHtml
});

in 1.0.3

  • remove singleton eventemitter and make gitImager object have its own eventemitter.