Removing Scheduled Tasks from the Menus

While working on A Task to Retrieve URL Content, several improvements were found for Scheduled Tasks:

  • Previously the automated tasks were just listed as completed tasks. If they are running automatically, there's little value in seeing them. Also, they still take up screen space
  • If an automated task is removed, it can cause an error with the report or text missing. While error checking is good for a missing report, its also a good idea to de-automate the task in the remove call

Hiding a task when automating it doesn't take it away the search results. It add more use for the Add a Scheduler Report - all of the automated tasks can be displayed in its report.

Posted by John Borden at 13 September 2020, 12:54 pm link

A Task to Retrieve URL Content

There have been several times that I have found that it would be useful if my todo list would react to another site. For example, if a business is temporary closed for a pandemic, I would like a todo item activated when it is open again. Another use case is moving the task of watering plants to a later date when it is likely to rain.

The method PRScheduledTaskExamples>>reportCheck:thenRetrieveLink:using:onPageAt: implements this for Scheduled Tasks, steps are:

  1. The report check to determine if it should proceed by returning true or false. It accepts the report page as an argument.
  2. Retrieve the contents of the URL, handle any connection errors by displaying in the report page
  3. Pass the URL contents to the using-block. This should return a string to be displayed on the report page

This code should be loaded into a newer version of Pharo 8, using older version (like from this problem) had image crashes retrieving https URLs.

Testing - Reading this page:

  1. Create a ToDo List with two tasks:
    1. One task is Use My Subscription to The Business - Repeats every 5 days
    2. Second is Check the Business
      • it repeats every 10 minutes and has a report child with empty text
      • The check task has the contents: (PRScheduledTaskExamples newForKernelNamed: 'pier') reportCheck: [ :page | '*Aug*' match: page contents ] thenRetrieveLink: 'http://www.myborden.com/pier/john-c-borden/updates/todo-retrieves-url' using: [ :string | ('*temporary closed for a pandemic*' match: string) ifTrue: [ (PRPathLookup start: (PRKernel instanceNamed: 'pier') root path: '/Todo/Use My Subscription to The Business') hideFromMenus: true. 'the business is still closed' ] ifFalse: [ (PRPathLookup start: (PRKernel instanceNamed: 'pier') root path: '/Todo/Use My Subscription to The Business') hideFromMenus: false. (PRPathLookup start: (PRKernel instanceNamed: 'pier') root path: '/Todo/Check the Business') deautomate. 'Open for business' ] ] onPageAt: '/Todo/Check the Business/report'.
      • Automate this task by running in the image: (PRPathLookup start: (PRKernel instanceNamed: 'pier') root path: '/Todo/Check the Business') automate.
      • inspect: TaskScheduler allInstances anyOne to ensure that this is running
  2. Wait 10 minutes, the report page should display that the check failed, but it lists the date (testing this in August)
  3. Wait 10 minutes more, check the page again. The 'Use My Subscription' should be hidden, the 'Check' should report that the business is closed
  4. Update the page at the URL, change the spelling of the checked words
  5. Wait 10 minutes
  6. The Subscription tasks should be visible again
  7. Check again: TaskScheduler allInstances anyOne inspect - The check business task should not be present

Design Choices

Fetching the contents of a URL is quite time-consuming, and introduces additional dependencies on other systems. For tasks like monitoring another site, this is the intention so the check block can simply be: [ :ignore | true ] and the check won't fail. Other examples like the plant watering example can check the state of the other tasks. Using the report page (like the testing example) allow it to implement a state-machine.

Code changed for this includes:

  • Adding PRToDoTask>>deautomate
  • Modify PRToDo>>tasks to only return tasks which are not hidden from the menus
  • For some reason, JQAjax>>callback: still had a call to #fixCallbackTemps, this has been removed from Pharo 8
Posted by John Borden at 28 August 2020, 2:07 am link

FFI Load Failure

When Agile Artificial Intelligence was published as a book I was so excited to pick up a copy. I was quite surprised to see my name in the acknowledgements even though I had only contributed a few suggestions.

One of the interesting examples in the book is using FFI (Foreign Function Interface) to utilize C for matrix operations. This was something new to me, but I was disappointed to see that the MMAtrixTest fail with the error:

Error: External module not found

I moved matrix.dylib to several different directories including the bin and MacOS/Plugins but nothing worked. Testing the same code on RedHat Linux was successful, but not not as enjoyable as working on the Mac. Finally I tried installing Pharo 8 again (upgrading from vers. 68021 to vers. 6521), and the code was suddenly successful. It seems that using Pharo Launcher would be a good practice.

Posted by John Borden at 18 July 2020, 2:42 pm link

Missing Favicon

The file favicon.ico is a file that appears as an icon for the webpage. This file can generally be found in the root director - for example: https://www.google.com/favicon.ico is a G representing Google, likewise a lighthouse for pharo.org:

Server Alias
The favicon can either be found in the root directory (like the google example), or as a link listed in the page header.

For Pier 5 and older, one would login as root and open setting at the root page, choose the file in 'Shortcut Icon:'. For Seaside 3.2 pages have the following in the header:

<link rel="shortcut icon" type="image/png" href="/pier?_s=fe-YRIO0hdXYmPie"/>

Loading the same icon and setting up accordingly in a newer version has the source:

<link rel="shortcut icon" type="image/png" href="/pier?_s="/>

This does not display the icon correctly.

If NGinX is running in front of Pier, then it can be setup with the following work-around in the config file:

 location = /favicon.ico {
   alias /data/static/favicon.ico;
Posted by John Borden at 1 June 2020, 2:54 am with tags Pier link

Complete Task in List of Changes

Currently, when one clicks Changes for a ToDo list, it raises an error. The Changes view shows a logged-in user what has been updated, but clicking on a completed task brings up an error:

Unable to open 'Complete' in the current context

This should do something else. If a task is opened and a user clicks changes, it displays the editor on that task.

This is due to the following code:

	^ (super isValidIn: aContext) and: [ aContext structure isRoot not and: [ aContext structure parent isToDo ] ]

One reason the code is written this way is so the Complete option only shows up on the menu when a task is open - it doesn't make sense to "complete" the Syntax page. The menu is the gray text at the bottom of this page, or in the left pane of the default install:

Complete in bold for a task
The code related to this is:

isValidIn: aContext
	^ (super isValidIn: aContext)
		and: [ aContext command class = self
				or: [ aContext command isView
						and: [ aContext command viewComponentClass isNotNil
								and: [ aContext command viewComponentClass = PRChangesView ] ] ] ]

The scenarios that this handles are:

  • When viewing or editing a page which is not a task or todo option, the Complete menu option should not show up
  • When opening the changes view from a page that contains some child which is a ToDo Task, any time the task was completed should be listed, and clicking on the open link should access that page
  • The Complete menu option is only available when viewing a complete history item, it opens the normal pier page editor

The tests for equality make adding a subclass of PRCompleteToDoTaskCommand more difficult than necessary, but this code is sufficient to create a non-abstract test. This allows adding:

	^ false
	^ self viewComponentClass isNotNil
		and: [ self viewComponentClass = PRChangesView ]
	^ true

Then #isValidIn: can ask aContext's command if it should be displayed instead of performing checks itself.

Posted by John Borden at 26 April 2020, 10:31 pm with tags Pier link
<< 1 2 3 4 5 6 7 8 9 10 >>