Example Pier Import

Installing a new Pier instance can be done, but different steps are needed to upgrade a running pier wiki. The overall process is:

  1. export data into class
  2. export history into a file
  3. load the class data and create the wiki in a new image
  4. read the history text

Steps for exporting wiki:

| problemChars count |
count := 0.
(problemChars := Dictionary new)
        at: (Character value: 8217) put: $';
        at: (Character value: 8220) put: $";
        at: (Character value: 8221) put: $";
        at: (Character value: 8211) put: $-.
PRText allInstancesDo: [ :prText | (prText text includesAnyOf: problemChars keys) ifTrue: [ count := count + 1 .
               prText text: (prText text collect: [ :char | problemChars at: char ifAbsent: [ char ] ] ) ] ].
Transcript show: 'Updated '; show: count; show: ' text blocks.'.
Transcript cr; flush.

"Remove the old"
#PRKernelCreatorForPier asClassIfPresent: [ : c | c removeFromSystem].
"Export the wiki:"
PRKernelCodeExporter exportAsPier3Kernel: 'pier'.
#PRKernelCreatorForPier asClassIfPresent: [ : c | c fileOut].

New Image import:

Metacello new
  baseline:'Pier';
  repository: 'github://Pier-CMS/Pier3:UpdateEditor/repository';
  onConflictUseLoaded;
  load: 'addons'.

'PRKernelCreatorForPier.st' asFileReference ifExists: [ :file | file fileIn ].
PRKernel instances size = 1 ifTrue: [
  PRKernel instances anyOne name: 'pier_old'.
  #PRKernelCreatorForPier asClassIfPresent: [ :c | c new createKernel ].
  (WAAdmin defaultDispatcher handlerAt: 'pier') preferenceAt: #kernel put: (PRKernel instances detect: [ :e | e name ~= 'pier_old' ]) ].
WAAdmin defaultDispatcher defaultName: 'pier'.
WAAdmin applicationDefaults removeParent: WADevelopmentConfiguration instance.

(WAAdmin defaultDispatcher handlerAt: 'pier') libraries size = 2
  ifTrue: [ (WAAdmin defaultDispatcher handlerAt: 'pier')
    addLibrary: PRWysiwygFileLibrary;
    addLibrary: JQDeploymentLibrary;
    addLibrary: JQUiDeploymentLibrary;
    addLibrary: PRYUIEditorDeploymentLibrary;
    addLibrary: PRYUIEditorLibrary;
    addLibrary: JQOvercastTheme;
    addLibrary: JQWidgetBoxDeploymentLibrary ]
  ifFalse: [ Transcript show: 'WARNING: pier does not have two libraries! First should be PRBlueprintLibrary, second PRJavaScriptSupport'; cr ].

WAAdmin defaultDispatcher unregister: (WAAdmin defaultDispatcher handlerAt: 'tools').
WAAdmin defaultDispatcher unregister: (WAAdmin defaultDispatcher handlerAt: 'examples').
WAAdmin defaultDispatcher unregister: (WAAdmin defaultDispatcher handlerAt: 'tests').
WAAdmin defaultDispatcher unregister: (WAAdmin defaultDispatcher handlerAt: 'javascript').
WAAdmin defaultDispatcher unregister: (WAAdmin defaultDispatcher handlerAt: 'bootstrap').
WAAdmin defaultDispatcher unregister: (WAAdmin defaultDispatcher handlerAt: 'welcome').
WAAdmin defaultDispatcher unregister: (WAAdmin defaultDispatcher handlerAt: 'browse').

The below sets the password for http://localhost:8080/status and http://localhost:8080/config - default is seaside:

#('status' 'config')
	do: [ :name |
		(WAAdmin defaultDispatcher handlerAt: name) configuration
			addParent: WAAuthConfiguration instance.
		(WAAdmin defaultDispatcher handlerAt: name)
			preferenceAt: #login put: 'admin';
			preferenceAt: #passwordHash
				put: (GRPlatform current secureHashFor: 'seaside');
			addFilter: WAAuthenticationFilter new ].

(WAAdmin defaultDispatcher handlerAt: 'pier') configuration at: #maximumRelativeAge put: 3600.
Smalltalk vm maxExternalSemaphoresSilently: 512.
PRKernelCreatorForPier removeFromSystem.
PRKernel instances size = 2 ifTrue: [ PRKernel remove: 'pier_old' ].
10 timesRepeat: [ Smalltalk garbageCollect ].
"Tasks:
- Update auth in the extract, copy sanitized .st to S3
- When I click on settings on the main Pier page, it gives the error 'Internal Error: 3', when clicking 'edit' on http://localhost:8080/pier/system/components/StyleSheet, the same error pops up
"
PRFile allInstances anyOne.
Posted by John Borden link