Domonic: CDN

To quickly use and reference external assets when prototyping use the CDN package.

Currently there are 3 types of CDN. .js, .css and .img

Their features will be added here.

To use features from CDN they must be imported.

from domonic.CDN import *

Or just class you need

from domonic.CDN import CDN_JS

CDN_JS

script(_src=CDN_JS.JQUERY_3_5_1)

currently constants exist for:

  • JQUERY_3_5_1
  • JQUERY_UI
  • UNDERSCORE
  • BOOTSTRAP_4
  • POPPER_1_16_1
  • BOOTSTRAP_5_ALPHA
  • D3_6_1_0
  • MODERNIZER_2_8_3
  • MOMENT_2_27_0
  • PIXI_5_3_3
  • SOCKET_1_4_5

CDN_CSS

classless_css = link(_rel="stylesheet", _href=CDN_CSS.WATER_LATEST)

currently constants exist for:

  • BOOTSTRAP_5_ALPHA
  • BOOTSTRAP_4
  • MARX
  • MVP
  • WATER_LATEST
  • BALLOON
  • THREE_DOTS_0_2_0
  • MILLIGRAM_1_3_0

CDN_IMG

CDN_IMG has a placeholder service.

# to change it. do this...
CDN_IMG.PLACEHOLDER_SERVICE = "placebear.com/g"

img(_src=CDN_IMG.PLACEHOLDER(300,100))

# optional seperator if the site uses x instead of slash between dimensions
img(_src=CDN_IMG.PLACEHOLDER(300,100,'x'))

# there’s tons to pick from. (NOT ALL ARE HTTPS):

domonic.CDN

Refs to some useful .js and .css libs.

use for prototyping. wget anything in later and create your own local references once ur happy

TODO - integrity/cross origin/module?

WARNING/NOTE - dont use. this isn’t released or documented. just ideas atm…

class domonic.CDN.CDN_CSS[source]

Preferably use version numbers if available. user LATEST if it always gets the latest

class domonic.CDN.CDN_IMG[source]

CDN images

static PLACEHOLDER(width=100, height=100, HTTP='', seperator='/')[source]

to update do CDN_IMG.PLACEHOLDER_SERVICE = “placebear.com/g” usage : img(_src=CDN_IMG.PLACEHOLDER(300,100)) default HTTP is none, to let the browser decide # use optional seperator if the site uses x instead of slash img(_src=CDN_IMG.PLACEHOLDER(300,100,’x’))

class domonic.CDN.CDN_JS[source]

You will need to append the lib version number if you add any libs here # obvious candidates… https://github.com/sorrycc/awesome-javascript

domonic.utils

snippets etc

class domonic.utils.Utils[source]

utils

static case_camel(s: str)[source]

case_camel(‘camel-case’) > ‘camelCase’

static case_kebab(s: str)[source]

kebab(‘camelCase’) # ‘camel-case’

static case_snake(s: str)[source]

snake(‘camelCase’) # ‘camel_case’

static chunk(list, size)[source]

chunk a list into batches

static chunks(iterable, size, format=<built-in function iter>)[source]

Iterate over any iterable (list, set, file, stream, strings, whatever), of ANY size

static clean(lst)[source]

removes falsy values (False, None, 0 and “”) from a list

static dictify(arr)[source]

turns a list into a dictionary where the list items are the keys

static squash(the_list)[source]

turns a 2d array into a flat one

static untitle(str)[source]

fooBar

static url2file(url)[source]

gen a safe filename from a url

domonic.decorators

domonic.decorators.check(f)[source]

logs entry and exit of a function

domonic.decorators.instead(f, somethingelse)[source]

what to return if it fails

domonic.decorators.log(logger, level='info')[source]

@log(logging.getLogger(‘main’), level=’warning’)

domonic.decorators.silence(*args, **kwargs)[source]

stop a function from doing anything