On 01/07/2010 04:22, Pat Maddox wrote:
Is there a way to take individual pages from my local
machine and transfer them to the server?
I remembered having a few code snipets for doing this from a few months
back, on digging them out it turns out to be a bit more involved than I
remembered, and maybe more than you're looking for, but here it is
anyway. This is for the Pharo-based Pier 1.2 one-click install, and
mostly cribbed from how the Pier site-wide import/export widget works.
With a little work it could no doubt be turned into something rather
more convenient.
First, create these method in PRStructure (the dev machine will at least
need the export methods, the server will need the import method.)
--------------------
prepareForExport
self decorations do: [:decoration |
(decoration isKindOf: PUSecurity) ifTrue: [
self removeDecoration: decoration
].
self removeDecoration: PUSecurity ifAbsent: [].
].
----------------------
copyForExport
| copy |
copy := self veryDeepCopy.
copy enumerator with all do: [:each | each prepareForExport].
copy parent: nil.
^copy
--------------------
attachImport
PRExportImportWidget new sanitizeImport: self.
self enumerator with all do: [:each |
(each isKindOf: PSRScreenNewStructure) ifTrue: [
each psrModel attachImport
]
].
--------------------
Then, on the dev machine, paste the following line into a workspace and
"explore" it:
PRKernel instances anyOne root enumerator with all select: [:each | each
name = 'my page name'].
In the explorer window, select the entry for your page, paste the
following into the code pane underneath, and "do" it.
---------------------
(FileDirectory default fileNamed: 'export.obj') in: [:fs |
[(ReferenceStream on: fs) in: [:refs |
refs nextPut: self copyForExport; close
]] ensure: [fs close]
].
----------------------
Copy the export.obj (or whatever you've called it) to the server.
On the server, use the same "explore" line as above to select the page
that you want as the PARENT of your imported page, and "do" the
following in the code pane to import your page.
----------------------
(FileDirectory default readOnlyFileNamed: 'export.obj') in: [:fs |
[(ReferenceStream on: fs) next in: [:newPage |
newPage root name: (PRAddCommand new uniqueName: newPage name in: self).
self addChild: newPage.
newPage attachImport.
]] ensure: [fs close]
].
----------------------
HTH
Nick Brown