Resources Management

It’s been some time since I wrote something here. I can only say I’m sorry for those who are waiting for so long to take Hokus for a spin. As an apology, there is a new video at the end of this post.

The good news is that project is going very well. I’m finally happy with the new BundleManager component.

I had to change a lot of the DynamicForm component, which is the ancestor of all components used to build a form, to accommodate the new rules introduced by the new component (the BundleManager). I had to perform a huge refactory to avoid component coupling.

I also spended a long time working to find a way to generate nice thumbnails from uploaded images without freezing the application.

But that’s enough of writing. I’ll cut the crap and show you the new components working.

Below, the configuration to setup a collection using two BundleManagers, like the one used in the demo. The sample is a JSON formatted file, but could be TOML or YAML as well.

{
   "key":"pages",
   "title":"Pages",
   "itemtitle":"Page",
   "dataformat":"toml",
   "extension":"md",
   "folder":"content/",
   "fields":[
      {
         "key":"title",
         "title":"Title",
         "type":"string"
      },
      {
         "key":"mainContent",
         "title":"Content",
         "type":"markdown"
      },
      {
         "key":"pubdate",
         "title":"Pub Date",
         "type":"date"
      },
      {
         "key":"draft",
         "title":"Draft",
         "type":"boolean"
      },
      {
         "key":"resources",
         "title":"Resources",
         "type":"nest",
         "fields":[
            {
               "key":"images",
               "title":"Images",
               "type":"bundle-manager",
               "path":"images",
               "extensions":[
                  "png",
                  "jpg",
                  "jpeg",
                  "gif"
               ],
               "fields":[
                  {
                     "key":"name",
                     "title":"Name",
                     "type":"string"
                  },
                  {
                     "key":"featured",
                     "title":"Featured",
                     "type":"boolean"
                  },
                  {
                     "key":"thumb",
                     "title":"Thumbnail",
                     "type":"bundle-image-thumbnail"
                  }
               ]
            },
            {
               "key":"docs",
               "title":"Documents",
               "type":"bundle-manager",
               "path":"docs",
               "extensions":[
                  "txt",
                  "docx"
               ]
            }
         ]
      }
   ]
}

Comments