Today weโve started, but not finished, bedding down the โwatchdogโ aspects to our โSass Watch Supervisor and Watchdogโ PHP web application, augmenting the (mainly) โsupervisorโ progress of yesterdayโs Sass CSS Stylesheet Supervisor Execution Tutorial.
Primarily what we need further work on is the reliable stopping of processes should the user decide to quit all Sass Watching, and the โupdateโ mode of โsurfing the netโ non-initial executions, where we have added a new โStop Watchdogโ button to get the job into perspective.
Also, as you can see below, we have all the PHP modes of use helping out โฆ
$ diff sass_watchdog.php--GETME sass_watchdog.php-GETME | grep ' // '
< function undochecks() { // can be done via command line or surfing the net POST
< function dochecks() { // done via curl
< if (isset($_GET['check'])) { // done via curl
< } else if (isset($_POST['uncheck'])) { // done via surfing the net
< } else if (isset($_GET['in1']) && isset($_GET['out1'])) { // done via surfing the net
< } else if (isset($_POST['in1out1']) && !isset($_POST['check'])) { // done via surfing the net
< } else { // done via surfing the net
< } else { // done via command line
> } else { // command line
โฆ as โsurfing the netโ is good at gathering user information, โcommand lineโ is good at a single continuously running (until killed) background process that periodically uses a โcurlโ call execution to check for processes that have fallen over and need resurrecting. As you can imagine from this design, you have to kill the โcommand lineโ process to get anywhere stopping Sass Watching work.
Again, with todayโs work, it is best for you to download thechanged sass_watchdogphp and work it into a local web server arrangement, such as a MAMP one, we still offer you a live
run link. Alas, you cannot see any โwatchdogโ work in action with that link, as nothing is really kicked off on the rjmprogramming.com.au domain.
Previous relevant Sass CSS Stylesheet Supervisor Execution Tutorial is shown below.
Of course weโd like to quickly get to the โwatchdogโ aspects of yesterdayโs Sass CSS Stylesheet Supervisor Watchdog Tutorial, but we need to tie down the โsupervisorโ parts, in progress today, where they are submitted as background tasks that run until killed (sorry for the harsh words, but โkillโ is the terminology in a lot of operating systems to stop a process or task). That progress makes us believe that, yes, we will be able to create a โSass Watch Supervisor and Watchdogโ not needing crontab and just having the one PHP source code file. And yes, we think weโll definitely take advantage of all/most of PHPโs โฆ
- surfing the net
- command line
- curl
โฆ modes of use, either using all three, or at least the first two above. Part of that design, in our mind, is that an initial โsurfing the netโ execution run, where filesets are filled in with that table, form the basis for self-adjustment of the PHP code settings. That important first real run sets up arrangements necessary, that any subsequent incarnations of executions will have enough information to do what crontab arrangements could have been harnessed to do. Please note, though, that Windows has Task Scheduler that can achieve crontab background processing too.
And so to todayโs work, progress is in large part based on the PHP function startBackgroundProcess presented there, thanks. It concerns the central tenet of the โSass Watch Supervisor and Watchdogโ concept, that of being able to execute โฆ
-
sass --watch inputSassStylesheet1.scss outputStylesheet1.css >> log.file 2>> errorlog.file & - for as many โmappingsโ (ie. as above 1 to 2, as above 1 to 3 etcetera etcetera etcetera) as the user so desires
With todayโs work, though, it is best for you to download thechanged sass_watchdogphp and work it into a local web server arrangement, such as a MAMP one, we still offer you a live
run link opportunity (but do not follow through with the โSuperviserโ action) for you to imagine how all this โSass Watch Supervisor and Watchdogโ could work for you, on that positive โSupervisorโ side of the ledger (the โWatchdogโ aspects being more the โbut what ifโ side of the ledger).
Previous relevant Sass CSS Stylesheet Supervisor Watchdog Tutorial is shown below.
Adding genericity to yesterdayโs Sass CSS Stylesheet Background Crontab Tutorial we โฆ
- choose to write the one codefile for purposes of (Sass CSS Stylesheet) Supervision (ie. filename collection) and Maintenance (watchdog duties) โฆ and so we โฆ
- pick PHP as that bridge between Windows and Mac & Linux โฆ
- pick PHP in case we need both a โsurfing the netโ and/or โcommand lineโ requirement for the โSupervisor Watchdogโ
โฆ and weโve started down the โsupervision roadโ today, and will continue onto โwatchdogโ (and more โsupervisionโ) nuances into the future days.
What is needed to start off on (Sass CSS Stylesheet) Supervision? Anyone, anyone? Yes, Zhang Qian, we need a โlinked listโ type of arrangement collecting off the user the names of โinput Sass *.scssโ stylesheet files and what โoutput *.cssโ stylesheet one to one conversion should happen. We decide to use a table to hold this information, starting with that first fileset of interest, that if filled in properly โฆ
- has onblur event logic that both โฆ
- saves away that setting (within the form method=POST that can self navigate back via $_POST arguments back in) โฆ
- as well as adding another blank table row for another potential user fileset entry โฆ โlinked list styleโ
โฆ the sass_watchdogphp PHP code of which you can try yourself with todayโs live
run link, that just collects user entries at this stage.
Previous relevant Sass CSS Stylesheet Background Crontab Tutorial is shown below.
Yesterdayโs Sass CSS Stylesheet Primer Tutorial showed a really promising procedural CSS stylesheet creator tool โฆ
sass --watch [inputSassSCSS] [outputCSS]
โฆ in action, but the mode of that procedural application of that โฆ
- sass โwatch [inputSassSCSS] [outputCSS] # in a Mac OS X (or macOS) terminal window command line โฆ held up the further use of that window, because it is a foreground process โฆ and so jarred with us โฆ but todayโs work, good for Linux and/or Mac OS X (or macOS) โฆ and which you can see in action with todayโs PDF
slideshow โฆ allows for โฆ
- Linux or Mac OS X (or macOS) โฆ
- sass โwatch [inputSassSCSS] [outputCSS] & # in a Mac OS X (or macOS) terminal window command line run as a background process that remains even after logout, which is mostly all you need, except that โsass โwatchโ process can fallover โฆ so โฆ
- crontab controlled Sass โwatchdogโ (remember Linux Watchdog Primer Tutorial) โฆ that checks on whether Sass โwatchdogโ is running, and whether a (CSS stylesheet) file set check instance execution is running โฆ
#!/bin/ksh
# supervise_sass.ksh
# RJM Programming
# Make sure "sass --watch base.scss build/test.css" is running
if [ -z "`ps -ef | grep -v 'grep' | grep -c 'supervise_sass.ksh' | sed '/10/s//21/g' | sed '/1/s///g' | sed '/0/s///g'`" ]; then
while [ 0 -lt 1 ]; do
if [ -z "`ps -ef | grep -c 'build/test.css' | sed '/10/s//21/g' | sed '/1/s///g' | sed '/0/s///g'`" ]; then
/usr/local/Cellar/sass/1.22.12/bin/sass --watch /Applications/MAMP/htdocs/sass/base.scss /Applications/MAMP/htdocs/sass/build/test.css >> /Applications/MAMP/htdocs/sass/sass_watch.ok 2>> /Applications/MAMP/htdocs/sass/sass_watch.notok &
fi
sleep 10
done
fi
exit
โฆ (a Sass โwatchdogโ) called supervise_sassksh โฆ via โฆ crontab -l โฆ
* * * * * ksh -c "/Applications/MAMP/htdocs/supervise_sass.ksh >> /Applications/MAMP/htdocs/ss.xxx 2>> /Applications/MAMP/htdocs/ss.notxxx"
โฆ and note how what โsassโ represents (in commands) needed to be written in โlonghand path termsโ in crontab land, because you should not assume anything about the environment associated with crontab
โฆ which is good now โfor leave it (ie. Sass CSS Stylesheet preprocessing) to look after itself, and resurrect itselfโ. But tomorrow we want more genericity regarding โฆ
- more Windows friendly aspects to โwatchdogโ talk
- allow for multiple (CSS stylesheet) file set arrangements โฆ but also (a more thorough โwatchdogโ should) โฆ
- allow for a โcomplete shutdown, and not resurrectโ mode of use
Previous relevant Sass CSS Stylesheet Primer Tutorial is shown below.
When compartmentalizing web design work, and youโve already done a compartmentalization to โฆ
- backend โ (ie. โthe dataโ, โthe configurationโ) โฆ and โฆ
- frontend โ (ie. โthe lookโ, โthe functionalityโ)
โฆ a very natural, and intuitive way to divvy up some of the tasks for โfrontendโ above, a programmer or developer or team could work on โฆ
CSS styling
โฆ both in a โฆ
- project wide CSS styling sense โฆ and into โฆ
- nuances for exceptional webpages, perhaps
โฆ and it is here that we think todayโs (โHello Worldโ-ish) trial of the Sass (โSyntactically Awesome Style Sheetsโ) command line product should be of interest for you.
Letโs list in broad brush terms what Sass is capable of as far as CSS styling goes, and which we show you a stream of consciousness view of with todayโs PDFslideshow presentation (showing you an install on a MacBook Pro, and showing its features, and the mock up of a Sass *.scss file along with its imagined โsass โwatchโ manipulation to change the look of a mockup webpage) โฆ
- ability to preprocess, facilitating that compartmentalization thought above, command line โsass โwatchโ option can have a developer working on CSS stylesheet files (separately to other developers working on HTML (or server developers on PHP), separately to other developers working on Javascript) that are not the live CSS files, one step removed via โsassโ looking out for changes and automatically building the live CSS files when Sass *.scss files are saved โฆ as well as syntax and cross-browser thoughts such as โฆ
- ability to include snippets (โpartialsโ) or import from other Sass *.scss stylesheet files
- ability to have Sass variables
- ability to handle Sass nesting syntax
- ability to include Sass mixins to help with those cross-browser prefix (eg. โ-webkit-โ, โ-ms-โ) directive complications
- ability to share Sass (CSS) properties from one selector to another (โextend/inheritโ)
- ability to do mathematics via Sass โoperatorsโ helping convert hard-coded dimensions in pixels (px) to percentage (%) values better for responsive design principles
We hope you try out this wonderful software tool for yourself.
If this was interesting you may be interested in this too.
If this was interesting you may be interested in this too.
If this was interesting you may be interested in this too.
If this was interesting you may be interested in this too.
If this was interesting you may be interested in this too.