vieweditattachhistoryswikistopchangessearchhelp

新規ページ作成時にページオブジェクトを作らず、初回保存時に作る

refs → templates (page) → newLink
<a href="<?toCreate?>?name=<?newSendName?>"><b><?newShowNameWithAlias?></b></a><?createType?>


refs → actions (page) → toCreate "移動用アクション作成"
request referenceShelf: shelf book: book address: 'create'


refs → addresses (book) → create "入力フォーム表示用アドレス作成"
book formatBookTemplate: 'create' request: request response: response shelf: shelf


refs → templates (book) → create "入力フォームテンプレート作成"
<?doctype?>
<html>
<head>
<title>新規ページの作成</title>
<?endHead?></head>
<body<?colorScheme?>>
<?beforeButtons?><?showButtons?><?afterButtons?>
<br><br>
<form action="<?toNew?>" method=post>
<b>タイトル&nbsp;<font color=gray>(参照元でのリンク名)</font>&nbsp;:</b>&nbsp;&nbsp;<input type="text" size=50 value="<?initName?>" name="name">
<br><br>
<textarea name="text" rows=20 cols=90 wrap=virtual><?editText?></textarea><br>
<input type="submit" value="この内容で新しいページを作成"><br>
</form>
<?endBody?></body>
</html>


refs → actions (book) → initName "ページ名称ゲッタアクション作成"
request fieldsKey: 'name' ifAbsent: ['名称未設定']


refs → actions (book) → editText "ページソース欄作成用アクション作成"
book formatBookTemplate: 'newText' request: request response: response shelf: shelf


refs → actions (book) → toNew "入力確定時移動先アドレス生成用アクション作成"
request referenceShelf: shelf book: book page: book pages first address: 'create'


refs → templates (book) → newText "新規ページデフォソーステンプレート作成"
申しわけありません。まだ <?initName?> についての記述はありません。
Webブラウザの「戻る」ボタンで、もとの画面に戻れます。


refs → addresses (page) → create "新規ページ作成処理用アドレス作成"
"Create a new page"
| newPage scheme type |
(request fieldsHasKey: 'name')
	ifTrue: [(book hasPageNamed: (request fieldsKey: 'name'))
		ifTrue: [book formatPageTemplate: 'editUnlockedResolve' 
			request: request 
			response: response 
			shelf: shelf 
			page: (book pageNamed: (request fieldsKey: 'name'))]
		ifFalse: ["Add New Page"
			newPage _ book addNewPage.
			newPage
				forbidWriting;
				date: Date today;
				time: Time now;
				name: (request fieldsKey: 'name');
				user: 'unknown'.
			type _ request fieldsKey: 'type' ifAbsent: ['text-default'].
			(book formatPrivAddress: 'allSchemes' request: request response: response shelf: shelf) do: [:i |
				 ((i at: 1) = (page settingsAt: 'scheme' ifAbsent: ['default'])) ifTrue: [scheme _ i]].
			((scheme at: 4) = 'default') ifFalse: [newPage settingsAt: 'scheme' put: (scheme at: 4)].
			(type beginsWith: 'text-')
				ifTrue: [(type = 'text-default')
					ifTrue: [newPage text: (request fieldsKey: 'text' ifAbsent: [''])]
					ifFalse: [newPage
						text: '';
						settingsAt: 'template' put: (type copyFrom: 6 to: type size)]]
				ifFalse: [
					newPage
						text: '';
						settingsAt: 'isText' put: false.
					(type = 'project-default') ifFalse: [newPage
						settingsAt: 'template' put: (type copyFrom: 9 to: type size)]].
			[newPage
				user: (shelf formatPrivAddress: 'getIPName' request: request response: response);
				write;
				permitWriting] fork.
			(book pages select: [ :pg | pg textContains: newPage name, '*' caseSensitive: true ]) do: [ :pg |
				(pg settingsAt: 'isText' ifAbsent: [true]) ifTrue: [[ pg
					forbidWriting;
				 	updateFormatRequest: request response: response shelf: shelf book: book;
					permitWriting ] fixTemps; fork]].
			response at: 'headerStatus' put: #tempMoved.
			response at: 'location' put: (request referenceShelf: shelf book: book page: newPage).
			book formatPageTemplate: 'newSuccess' request: request response: response shelf: shelf page: newPage]]
	ifFalse: [response at: 'headerStatus' put: #notFound.
		book formatBookTemplate: 'addressNotFound' request: request response: response shelf: shelf]


refs → addresses (priv) → secrity "要所に addAddress: 'create.page'; を追加"
"name, description, privileges
 name=aString
 description=aString
 privileges=aSwikiSecurityPrivileges"
| values value |
values _ OrderedCollection new.
"Deny All"
value _ Array new: 3.
value
	at: 1 put: 'Deny All';
	at: 2 put: 'No access to the site at all';
	at: 3 put: (SwikiSecurityPrivileges named: 'Deny All' default: false).
values add: value.
"Read Only"
value _ Array new: 3.
value
	at: 1 put: 'Read Only';
	at: 2 put: 'Only able to view the site';
	at: 3 put: ((SwikiSecurityPrivileges named: 'Read Only' default: true)
		addAddress: 'append.page';
		addAddress: 'upload.page';
		addAddress: 'attach.page';
		addAddress: 'edit.page';
		addAddress: 'new.page';
		addAddress: 'create.page';
		addAddress: 'render.book';
		addAddress: 'save.page';
		yourself).
values add: value.
"Read & Append"
value _ Array new: 3.
value
	at: 1 put: 'Append';
	at: 2 put: 'Able to view the site and use append areas.';
	at: 3 put: ((SwikiSecurityPrivileges named: 'Append' default: true)
		addAddress: 'upload.page';
		addAddress: 'attach.page';
		addAddress: 'edit.page';
		addAddress: 'new.page';
		addAddress: 'create.page';
		addAddress: 'render.book';
		addAddress: 'save.page';
		yourself).
values add: value.
"Write"
value _ Array new: 3.
value
	at: 1 put: 'Write';
	at: 2 put: 'Able to edit pages, but cannot upload files.';
	at: 3 put: ((SwikiSecurityPrivileges named: 'Write' default: true)
		addAddress: 'upload.page';
		addAddress: 'attach.page';
		addAddress: 'render.book';
		yourself).
values add: value.
"Allow All"
value _ Array new: 3.
value
	at: 1 put: 'Allow All';
	at: 2 put: 'Able to do anything';
	at: 3 put: (SwikiSecurityPrivileges named: 'Allow All' default: true).
values add: value.
values

このページを編集 (5820 bytes)


Congratulations! 以下の 1 ページから参照されています。

This page has been visited 2549 times.