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

koco-content-management

v3.0.4

Published

A set of utilities to help build a CMS

Downloads

11

Readme

koco-content-management

koco content management is a component used to create listing and editing pages for content management systems (CMS). It is an opinionated component based on the koco generator.

Table of contents

Installation

bower install koco-content-management --save

Creating a content listing page

About content listing page

//TODO

Setup

Activator for content listing page (optional)

You can use the default activator (see koco-router activator contract for more information) by first adding this to your require.config.js file

paths: {
  ...
  'content-list-page-base-activator': 'bower_components/koco-content-management/src/listing/content-list-page-base-activator'
  ...
}

and then creating an activator that inherits from the content-list-page-base-activator

define(['./my-list-page-viewmodel', 'content-list-page-base-activator'],
    function(MyEditPageViewModel, ContentEditPageBaseActivator) {
        'use strict';

        var Activator = function() {
            var self = this;

            ContentEditPageBaseActivator.call(self, new MyEditPageViewModel());
        };

        Activator.prototype = Object.create(ContentEditPageBaseActivator.prototype);
        Activator.prototype.constructor = Activator;

        return Activator;
    });

Base ViewModel for content listing page

paths: {
  ...
  'content-list-page-base-viewmodel': 'bower_components/koco-content-management/src/listing/content-list-page-base-viewmodel'
  ...
}
  • Create a shareable viewmodel that is different than the main viewmodel -ui.js (the shareable viewmodel will be joined with the main viewmodel after the activation process). This shareable viewmodel should extend (see jQuery extend for more information) the base viewmodel (content-list-page-base-viewmodel) like this:

my-list-page-viewmodel.js -->

define(['knockout', 'jquery', 'content-list-page-base-viewmodel', 'my-rest-api'],
    function(ko, $, ContentEditPageBaseViewModel, myRestApi) {
        'use strict';

        //For example
        var defaultSearchFields = {
            keywords: ''
        };

        var MyEditPageViewModel = function() {
            var contentEditPageBaseViewModel = new ContentEditPageBaseViewModel(myRestApi, 'myRestApiResource', defaultSearchFields);
            $.extend(contentEditPageBaseViewModel, this);
            var self = contentEditPageBaseViewModel;

            return self;
        };

        return MyEditPageViewModel;
    });
  • Create the main viewmodel for your content listing page. The main viewmodel will receive the shareable viewmodel as the context argument:

my-list-page-ui.js -->

define(['knockout', 'jquery', 'text!./my-list-page.html'],
    function(ko, $, template) {
        'use strict';

        var MyEditPageViewModel = function(context, componentInfo) {
            var self = this;

            $.extend(context, self);
            self = context;

            return self;
        };

        return {
            viewModel: {
                createViewModel: function(context, componentInfo) {
                    var viewmodel = new MyEditPageViewModel(context, componentInfo);

                    return viewmodel;
                }
            },
            template: template
        };
    });

Creating a content editing page

About content editing page

//TODO

Setup of content editing page

Activator for content editing page (optional)

You can use the default activator (see koco-router activator contract for more information) by first adding this to your require.config.js file

paths: {
  ...
  'content-edit-page-base-activator': 'bower_components/koco-content-management/src/listing/content-edit-page-base-activator'
  ...
}

and then creating an activator that inherits from the content-edit-page-base-activator

define(['./my-edit-page-viewmodel', 'content-edit-page-base-activator'],
    function(MyEditPageViewModel, ContentEditPageBaseActivator) {
        'use strict';

        var Activator = function() {
            var self = this;

            ContentEditPageBaseActivator.call(self, new MyEditPageViewModel());
        };

        Activator.prototype = Object.create(ContentEditPageBaseActivator.prototype);
        Activator.prototype.constructor = Activator;

        return Activator;
    });

Base ViewModel for content editing page

paths: {
  ...
  'content-edit-page-base-viewmodel': 'bower_components/koco-content-management/src/editing/content-edit-page-base-viewmodel'
  ...
}
  • Create a shareable viewmodel that is different than the main viewmodel -ui.js (the shareable viewmodel will be joined with the main viewmodel after the activation process). This shareable viewmodel should extend (see jQuery extend for more information) the base viewmodel (content-edit-page-base-viewmodel) like this:

my-edit-page-viewmodel.js -->

define(['knockout', 'jquery', 'content-edit-page-base-viewmodel', 'my-rest-api'],
    function(ko, $, ContentEditPageBaseViewModel, myRestApi) {
        'use strict';

        //For example
        self.defaultContent = {
            id: null,
            title: ''
        };

        var MyEditPageViewModel = function() {
            var contentEditPageBaseViewModel = new ContentEditPageBaseViewModel(myRestApi, 'myRestApiResource', ko.mapping.fromJS(self.defaultContent));
            $.extend(contentEditPageBaseViewModel, this);
            var self = contentEditPageBaseViewModel;

            return self;
        };

        return MyEditPageViewModel;
    });
  • Create the main viewmodel for your content editing page. The main viewmodel will receive the shareable viewmodel as the context argument:

my-edit-page-ui.js -->

define(['knockout', 'jquery', 'text!./my-edit-page.html'],
    function(ko, $, template) {
        'use strict';

        var MyEditPageViewModel = function(context, componentInfo) {
            var self = this;

            $.extend(context, self);
            self = context;

            return self;
        };

        return {
            viewModel: {
                createViewModel: function(context, componentInfo) {
                    var viewmodel = new MyEditPageViewModel(context, componentInfo);

                    return viewmodel;
                }
            },
            template: template
        };
    });

Registering Content Pages

The content management comes with a utility function that works well with koco and can be used this way:

// require.config.js
paths: {
    ...
    'content-management': 'bower_components/koco-content-management/src/content-management'
    ...
}
// components.js
define([..., 'content-management'], 
    function(contentManagement) {
        ...
        contentManagement.registerContentPages('my-content', {
                withActivator: true, //default:true
                editTitle: 'Editing My Content',
                listTitle: 'Listing My Content',
                listContentName: '' //default:adds an 's' at the end of the provided content name
            })
        ...
        });