@dg1com/kina-tools

Public KinaTools lib for generating Kina url in DG1.com

Usage no npm install needed!

<script type="module">
  import dg1comKinaTools from 'https://cdn.skypack.dev/@dg1com/kina-tools';
</script>

README

Kina tools for generating Kina Url from JS

How to make it shine

  1. npm install
  2. npm run build

Build generate 2 versions of lib for usage in node & browser (web)

After updating this lib next things needs to be checked:

  • Sirius dependency
  • CakeMonster core Lib

Usages

In Browser

<script type="application/javascript" src="KinaTools.js"></script>
KinaTools.createUrl(parameters);

In Node

import KinaTools from '@dg1com/kina-tools'
KinaTools.createUrl(parameters)

Lib usage

KinaTools has two main functionalities:

  • To return parameters according to the forwarded URL getParametersFromUrl(url)
  • To create appropriate URL depending on forwarded parameters. class initUrl(domain, client, clientRegion, resourcesDomain, fileId, fileName, actions) method: addActions(actions: String[] | Object[]) → returns url {String} actions parameter: Array of actions in the following format
const actions = [
   {
      "resize":{
         "width":35,
         "height":45,
         "aspectRatio":true,
         "minSize":true
      }
    
    },
   {
      "crop":{
         "points":[
            34,
            56,
            67,
            87
         ],
         "zoom":1.45     
       }
    
    },
   "original",
   "optimize",
   {
      "subDirectory":"0-15"
    },
   {
      "imageQuality":"90"
   },
   "fileinfo",
   {
      "format": "png"
   }
]

const parameters = {
        actions : actions,
        clientId: <clientValue>,
        domain  : <clientDomain>,
        fileId  : <fileId>,
        fileName: <fileName>
    }

const url = KinaTools.createUrl(parameters)

User need to replace values which are in "<>" brackets.

Actions are optional.