Skip to content

handful of python scripts to facilitate in web development and deployment.

Notifications You must be signed in to change notification settings

bustardcelly/python-tasks-for-webdev

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

python-tasks-for-webdev

handful of python scripts to facilitate in web development and deployment.

#css-concatenate# Concatenates url resource contents declared in @import directives of a single file. ###example### directory structure

|-project
	|---tools
		+- css-concatenate.py
	|---style
		+- main.css
		+- one.css
		+- two.css
	+- index.html

main.css

@import url("one.css");
@import url("two.css");
body {
	margin: 0;
	padding: 0;
}

one.css

ul {
	list-style: none;
}

two.css

a {
	text-decoration: none;
}

###usage###

$project> ./tools/css-concatenate.py ./style/main.css

###produces### main.css

ul {
	list-style: none;
}
a {
	text-decoration: none;
}
body {
	margin: 0;
	padding: 0;
}

##known shortcomings##

  • Currently only supports @import from local disk.
  • Not recursive; if resource itself has @imports, does not replace those.
  • Overwrites to input file.

#css_datauri# Data URI util.

Traverses a directory and encodes asset files to base64 and replaces relative URL references in CSS files with the base64 string. ###example### directory structure

|-project
	|---tools
		+- css_datauri.py
	|---style
		|-----assets
			+- image.png
		+- main.css

main.css

.background {
	background-image: url('assets/image.png')
}

###usage##

$project> ./tools/css_datauri.py style

###produces### main.css

.background {
	background-image: url('data:img/jpg;base64,/9j/4AAQSkZJRgABAQ...'
}

##known shortcomings##

  • Overwrites CSS files; no option for -output directory. As such, it is recommended first to copy all files over to a distribution directory before running the css_datauri task.
  • Finds only relative paths in CSS.
  • If supplied path starts with './' or ends in '/', relative path detection does not work properly; for now, ensure that the supplied directory argument does not have a prefixed './' or trailing '/'.

About

handful of python scripts to facilitate in web development and deployment.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages