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

firelogue

v0.1.0-pre-alpha

Published

> Roll your own Disqus-like comments solution powered by Firebase.

Downloads

2

Readme

Firelogue

Roll your own Disqus-like comments solution powered by Firebase.

  • Works with Firebase's free plan
  • Drop-in comment widget — just include a JS file
  • Supports multiple sites
  • Browser-based Management Console for administration

This is a bloddy pre-alpha. Use with care!

Installation

Download the firelogue-binary for your system:

Unpack the Zip-file and store the binary in a folder on your system, e.g. named ./firelogue.

Setup

First of all you need a project on Firebase — so create one. After that go to the project settings and enter "Service accounts"-tab. Click the button "Generate new private key" and store the resulting file as firebase-admin.json in the previously created ./firelogue folder besides the firelogue binary.

Log into Firebase

First of all open the ./firelogue folder in your Terminal and run …

$ ./firelogue login

This will open an OAuth screen in the browser, that authenticates the Terminal session on Firebase.

To check whether you're already in or with which user, run …

$ ./firelogue whoami

Create an admin user

To be able to log into the Firelogue Management Console, you need to create a user. To do that, run the following command in the Terminal …

$ ./firelogue create-user

There'll be prompts asking for an email address, a username and a password. Enter all the information and you're done.

Install Firelogue

When you're logged in with Firebase and you've created the admin user, you're almost prepared for installing Firelogue to your Firebase app. But there's still one piece missing: the Web API key. To obtain that, go back to the project settings of your Firebase app. The Web API key is displayed in the General settings. Copy it and pass it to the following command in the Terminal …

$ ./firelogue install --apiKey <the Web API key>

There's another, optional parameter to this command: the --region. By default the cloud functions, Fireloque uses to read and write comments, are located in europe-west1. If you want to choose a different location, pass the code to the install-command.

$ ./firelogue install --apiKey <the Web API key> --region <key of the code>

Find a list of available region codes here.

After the command has finished, Firelogue is ready for use! The URL to the Maagement Console is printed into the Terminal output as well as the URL of the script, that brings the comment widget on your sites.

Add a website to the Management Console

Take the URL to the Management Console from the Terminal output of the installation and log into the console in your browser. Then use the form to add a website. Firelogue will only store comments for websites, that have been set up in the Management Console in beforehand.

From the list of websites in the console, copy the website ID. You'll need that one, to include the comment widget into the site.

Include the comment widget

To include the widget into your site, paste the following snippet into the HTML of your website:

<script>
  window.firelogue = window.firelogue || [];
  window.firelogue.push((init) => {
    var options = {
      root: document.getElementById('comments'), // Empty <div /> that'll hold the widget
      websiteId: '<ID of current website>', // Get this from the Management Console
      pagePath: '/foo/bar/', // optional; Firelogue will use `location.pathname` if pagePath isn't set
    }
    var api = init(options); // See next section to learn what the API is for
  });
</script>
<script src="https://<Project ID>.firebaseapp.com/client/firelogue.js"></script>

Don't forget to replace the <Project ID> in the URL of the javascript file with the actual ID of your Firebase app!

The pagePath-property of the options object is optional. But be careful: if you can't ensure that your pages are available by a single URL only (e.g. the page might be served with and without leading slash), then you better set this property explicitly. Otherwise you might end up with multiple comment lists for the same content.

Using Firelogue with client-side routing

If your site relies on history.pushState for routing, you'll have to take care of re-initializing the Firelogue widget yourself. That's where the API comes into play, that got returned by the init-function.

The API is an object holding an update-method. If a visitor navigates to a new page of your site, you have to call this update-method and pass the pathname of the current page to it.

This might look something like this …

var api;

// Initialize Firelogue to obtain the API ...

function onHistoryChange() {
  api.update(location.pathname);
}

That's it. The widget will re-initialize and load the comments of the current page.

Styling the Firelogue widget

The Firelogue widget comes with a very basic styling. To align it visually with your website, you can use the data-firelogue-selectors to apply custom CSS styling.

[data-firelogue='app'] {
  padding: 16px;
  margin: 32px;
  border: 4px dotted fuchsia;
}

Beware: Do not use the classnames of the elements, since they're generated based on their content and might change in the future. Which will break your custom styling. The data-firelogue-attributes won't change, so you're on the save side using them.

Troubleshooting

If you have questions or running into problems, feel free to open an issue.

Contributors

Become a contributor.

License

MIT