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

@lcharette/configmanager

v4.1.0

Published

UI for core and custom site settings for UserFrosting 5.1

Downloads

10

Readme

Configuration Manager Sprinkle for UserFrosting 5

Donate Latest Version UserFrosting Version Software License Build PHPStan Codecov StyleCI

Configuration Manager sprinkle for UserFrosting 5. Lets you edit UserFrosting configs from the interface.

Help and Contributing

If you need help using this sprinkle or found any bug, feels free to open an issue or submit a pull request. You can also find me on the UserFrosting Chat most of the time for direct support.

Installation

To install in your Sprinkle :

  1. Add this package with Composer :

    composer require lcharette/uf_configmanager "~5.1.0"
  2. Edit your Sprinkle Recipe to include the ConfigManager as a Sprinkle dependency :

    \UserFrosting\Sprinkle\ConfigManager\ConfigManager::class
  3. Add Config Manager frontend assets dependencies :

    npm i --save @lcharette/configmanager@~5.1.0
  4. Add Config Manager & FormGenerator frontend entries to your webpack entries. Open webpack.config.js and add in const sprinkles { ... }:

    FormGenerator: require('@lcharette/formgenerator/webpack.entries'),
    ConfigManager: require('@lcharette/configmanager/webpack.entries'),
  5. Run :

    php bakery bake

Working example

The public/ directory serves as an example of ConfigManager. You can clone this repository and install as any UserFrosting 5 sprinkle :

  1. composer install
  2. php bakery bake
  3. php -S localhost:8080 -t public

Permissions

The migration will automatically add the update_site_config permission to the Site Administrator role. If it's not added automatically, you can run the UserFrosting\Sprinkle\ConfigManager\Database\Seeds\SettingsPermissions seed using the php bakery seed command or add it manually in the admin UI. To give access to the config UI to another user, simply add the update_site_config permission slug to that user role.

Add link to the menu

The configuration UI is bound to the the /settings route. Simply add a link to this route where you want it. The checkAccess make it so it will appear only for users having the appropriate permission. For example, you can add the following to the sidebar menu :

{% if checkAccess('update_site_config') %}
<li>
    <a href="{{site.uri.public}}/settings"><i class="fa fa-gears fa-fw"></i> <span>{{ translate("CONFIG_MANAGER.TITLE") }}</span></a>
</li>
{% endif %}

Adding custom config

Settings are separated by topics in the UI. Each topic is represented by a file, located in schema/config/. Unlike normal schema files, all entries needs to be wrapped inside a config key. A name and desc top-level entry will allow to define the title and description of the topic.

{
    "name" : "SITE.CONFIG",
    "desc" : "SITE.CONFIG.DESC",

    "config": { ... }
}

For example, to add an entry for site.title text and site.registration.enabled checkbox option in a "UserFrosting Settings" topic :

{
    "name" : "SITE.CONFIG",
    "desc" : "SITE.CONFIG.DESC",

    "config": {
        "site.title" : {
            "validators" : {
                "required" : {
                    "message" : "SITE.TITLE.REQUIRED"
                }
            },
            "form" : {
                "type" : "text",
                "label" : "SITE.TITLE",
                "icon" : "fa-comment"
            }
        },
        "site.registration.enabled" : {
            "validators" : {},
            "form" : {
                "type" : "checkbox",
                "label" : "SITE.REGISTRATION.ENABLED"
            }
        }
    }
}

NOTE Only .json are accepted. Yaml schemas are cannot be used for now.

License

By Louis Charette. Copyright (c) 2020, free to use in personal and commercial software as per the MIT license.