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

github-image-resizer

v0.0.3

Published

Resizes images pushed to Github and saves them to S3, replacing the original on Github with a lo-res version

Downloads

3

Readme

github-image-resizer

Build Status

Resizes images pushed to Github and saves them to S3, replacing the original on Github with a lo-res version

Why?

Responsive images for a static site.

We use jekyll, a static site generator, for our website and we edit it with Prose. Prose is a web app that connects directly to Github and allows somebody to edit markdown on Github without needing to use git or the command line.

Prose includes functionality to upload images to Github with a post. The problem is that our website is responsive, and we do not want to use the full-resolution image on smaller devices. There are online services to dynamically resize images on each request, but they cost money, and don't match the static site mentality.

Our solution is to convert each image to multiple sizes when we first upload it, then we replace the original image with a lo-res version that will load on initial page load. We then check the screen size of the website when it loads and load the correct sized image to replace the placeholder.

Installation

  1. Setup an account with Blitline which is free for 2hrs of processing a month, which is a lot of resizing images.

  2. Create an Amazon S3 bucket for your images.

  3. Make sure Blitline has permissions to write to your S3 bucket.

  4. Deploy this server to Heroku by clicking the button below. Copy the GITHUB_SECRET - you will need that for setting up the Github webhook.

    Deploy

  5. Create a webhook on your Github repo. Payload Url should be https://YOUR_APP_ID.herokuapp.com, Content Type should be application/json, Secret should be the same as the GITHUB_SECRET environment variable on your Heroku App. You should just send the push event. Set your webhook to active.

That's it (what do you mean "that's it"? that's a whole bunch of work!). When you make a push to Github that includes an image that matches /.+\.(jpg|jpeg|png|tif|tiff|gif)$/ then you will get a bunch of different sized images in your S3 bucket, and the original will be replaced with a lo-res version in your repo.

Testing

You will need to set a BLITLINE_APP_ID environment variable and a GITHUB_TOKEN for a testing account. Tests will create a temporary repo (named temp + current date stamp) and then delete it after tests complete.

npm install
npm test