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

apostrophe-preferences

v0.5.23

Published

A site-wide preferences menu with a custom schema.

Downloads

39

Readme

Apostrophe Preferences

THIS MODULE IS DEPRECATED FOR NEW PROJECTS. Apostrophe 2.x has a global preferences object built in. You do not need this module.

Apostrophe Prefrences introduces a site-wide preferences menu to Apostrophe editors. Given a schema, the preferences module will save and load preferences on every page across your site. Use this module when you wish to give users control over aspects of the site that don't fit neatly into page settings or site content.

In your app.js site configuration:

modules: {
  ...
  'apostrophe-preferences': {
    schema: {
      addFields: [
        {
          name: 'myPreference',
          label: 'My Preference',
          type: 'string'
        }
      ]
    }
  }
}

In outerLayout.html where your Apostrophe site-wide menu is defined:

{{ aposPreferencesMenu(permissions) }}

In templates, your site preferences are now available in the preferences variable.

Loading preferences where middleware doesn't run

This module now loads its content via middleware, so it's likely you'll always have the data in req.extras.preferences. However if you're writing a command line task, you might want to call the loader yourself:

var req = apos.getTaskReq();
return site.modules['apostrophe-preferences'].loader(req, function(err) {
  // req.extras.preferences is available here
});

If req.extras is not already defined it will be created for you.

Changelog

In version 0.5.22, existing data from the database is also trimmed of stale dynamic properties so it doesn't cause crashes when loading new ones.

In version 0.5.21, area/widget loaders and joins are executed properly, and stale related objects are not stored in the preferences collection. For existing preferences, hit save once to get the benefit of this fix.

In version 0.5.20, a bug was fixed causing a crash if the permissions object does not exist in outerLayout.

In version 0.5.19, the loader began running as middleware. For bc reasons, the self.loader method is called from the middleware, and has a new provision to gracefully ignore double invocation.

In versions 0.5.17-0.5.18, provision was made to guarantee req.extras.preferences exists as an empty object even if there is no data yet.

In version 0.5.16, it became possible to call the loader easily yourself in situations where page loaders are not ordinarily called.

In version 0.5.14, important security provisions were added. You must pass the permissions object as was always documented above. If, as found in some of our older projects, you were previously passing edit: true, you will need to fix that as we are now checking permissions properly.

Starting with version 0.5.14 we also refresh the page fully after preferences are saved. Since the preferences are global they tend to impact elements in the outer layout. Since they are edited rarely there is no real penalty for refreshing the page.