Sass CSS Stylesheet Watchdog Beginnings Tutorial
โœ‚๐Ÿƒ๐Ÿพโ€โ™€๏ธ๐Ÿƒ๐Ÿผโ€โ™‚๏ธ
๐Ÿ“–

Sass CSS Stylesheet Watchdog Beginnings Tutorial

Sass CSS Stylesheet Watchdog Beginnings Tutorial

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_watchdogโšซphp 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.

Sass CSS Stylesheet Supervisor Execution Tutorial

Sass CSS Stylesheet Supervisor Execution Tutorial

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_watchdogโšซphp 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.

Sass CSS Stylesheet Supervisor Watchdog Tutorial

Sass CSS Stylesheet Supervisor Watchdog Tutorial

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_watchdogโšซphp 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.

Sass CSS Stylesheet Background Crontab Tutorial

Sass CSS Stylesheet Background Crontab Tutorial

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) โ€ฆ
    1. 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 โ€ฆ
    2. 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_sassโšซksh โ€ฆ 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.

Sass CSS Stylesheet Primer Tutorial

Sass CSS Stylesheet Primer Tutorial

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 PDFโœ‚slideshow 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.

This entry was posted in eLearning, Operating System, Software, Tutorials and tagged , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *