mirror of
				https://github.com/flynx/pWiki.git
				synced 2025-11-04 04:50:09 +00:00 
			
		
		
		
	cleanup and simplification....
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
		
							parent
							
								
									8ab96d303e
								
							
						
					
					
						commit
						eb02bf82f6
					
				@ -67,7 +67,7 @@ object.Constructor('BasePage', {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	// a base page to be used as a base for cloning if root is of a 
 | 
						// a base page to be used as a base for cloning if root is of a 
 | 
				
			||||||
	// different "class"...
 | 
						// different "class"...
 | 
				
			||||||
	//__clone_base__: undefined,
 | 
						//__clone_proto__: undefined,
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
	// NOTE: this can be inherited...
 | 
						// NOTE: this can be inherited...
 | 
				
			||||||
	//store: undefined,
 | 
						//store: undefined,
 | 
				
			||||||
@ -407,19 +407,22 @@ object.Constructor('BasePage', {
 | 
				
			|||||||
		data = full ? 
 | 
							data = full ? 
 | 
				
			||||||
			args[0] ?? {} 
 | 
								args[0] ?? {} 
 | 
				
			||||||
			: data
 | 
								: data
 | 
				
			||||||
 | 
							var src = this.__clone_proto__ 
 | 
				
			||||||
 | 
								?? (this.root || {}).__clone_proto__
 | 
				
			||||||
 | 
								?? this.root
 | 
				
			||||||
 | 
								?? this
 | 
				
			||||||
		return Object.assign(
 | 
							return Object.assign(
 | 
				
			||||||
			full ?
 | 
								full ?
 | 
				
			||||||
				// full copy...
 | 
									// full copy...
 | 
				
			||||||
				this.constructor(this.path, this.referrer, this.store)
 | 
									// XXX src or this???
 | 
				
			||||||
 | 
									//this.constructor(this.path, this.referrer, this.store)
 | 
				
			||||||
 | 
									src.constructor(this.path, this.referrer, this.store)
 | 
				
			||||||
				// NOTE: this will restrict all the clones to the first 
 | 
									// NOTE: this will restrict all the clones to the first 
 | 
				
			||||||
				// 		generation maintaining the original (.root) page as 
 | 
									// 		generation maintaining the original (.root) page as 
 | 
				
			||||||
				// 		the common root...
 | 
									// 		the common root...
 | 
				
			||||||
				// 		this will make all the non-shadowed attrs set on the
 | 
									// 		this will make all the non-shadowed attrs set on the
 | 
				
			||||||
				// 		root visible to all sub-pages.
 | 
									// 		root visible to all sub-pages.
 | 
				
			||||||
				: Object.create(
 | 
									: Object.create(src),
 | 
				
			||||||
					(this.root || {}).__clone_base__
 | 
					 | 
				
			||||||
						?? this.root 
 | 
					 | 
				
			||||||
						?? this),
 | 
					 | 
				
			||||||
			{
 | 
								{
 | 
				
			||||||
				root: this.root ?? this,
 | 
									root: this.root ?? this,
 | 
				
			||||||
				location: this.location, 
 | 
									location: this.location, 
 | 
				
			||||||
@ -1134,8 +1137,6 @@ var wikiword = require('./dom/wikiword')
 | 
				
			|||||||
var pWikiPageElement =
 | 
					var pWikiPageElement =
 | 
				
			||||||
module.pWikiPageElement = 
 | 
					module.pWikiPageElement = 
 | 
				
			||||||
object.Constructor('pWikiPageElement', Page, {
 | 
					object.Constructor('pWikiPageElement', Page, {
 | 
				
			||||||
	__page_constructor__: Page,
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	dom: undefined,
 | 
						dom: undefined,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -1144,6 +1145,15 @@ object.Constructor('pWikiPageElement', Page, {
 | 
				
			|||||||
		wikiword: wikiword.wikiWordText,
 | 
							wikiword: wikiword.wikiWordText,
 | 
				
			||||||
	},
 | 
						},
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						__clone_constructor__: Page,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						__clone_proto: undefined,
 | 
				
			||||||
 | 
						get __clone_proto__(){
 | 
				
			||||||
 | 
							return (this.__clone_proto = this.__clone_proto 
 | 
				
			||||||
 | 
								?? this.__clone_constructor__('/', '/', this.store)) },
 | 
				
			||||||
 | 
						set __clone_proto__(value){
 | 
				
			||||||
 | 
							this.__clone_proto = value },
 | 
				
			||||||
 | 
						
 | 
				
			||||||
	// NOTE: setting location will reset .hash set it directly via either
 | 
						// NOTE: setting location will reset .hash set it directly via either
 | 
				
			||||||
	// 		one of:
 | 
						// 		one of:
 | 
				
			||||||
	// 			.location = [path, hash]
 | 
						// 			.location = [path, hash]
 | 
				
			||||||
@ -1191,19 +1201,6 @@ object.Constructor('pWikiPageElement', Page, {
 | 
				
			|||||||
		this.onLoad()
 | 
							this.onLoad()
 | 
				
			||||||
		return this },
 | 
							return this },
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// NOTE: cloning this will return .__page_constructor__ and not 
 | 
					 | 
				
			||||||
	// 		.constructor instances...
 | 
					 | 
				
			||||||
	// XXX can we use .__clone_base__ here??
 | 
					 | 
				
			||||||
	// 		...or can we avoid this alltogether???
 | 
					 | 
				
			||||||
	clone: function(){
 | 
					 | 
				
			||||||
		// NOTE: we only get full clones here specifically to copy all 
 | 
					 | 
				
			||||||
		// 		the relevant data...
 | 
					 | 
				
			||||||
		var page = object.parentCall(pWikiPageElement.prototype.clone, this, ...arguments)
 | 
					 | 
				
			||||||
		// mutate the constructor...
 | 
					 | 
				
			||||||
		this.__page_constructor__
 | 
					 | 
				
			||||||
			&& (page.__proto__ = this.__page_constructor__.prototype)
 | 
					 | 
				
			||||||
		return page },
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	// handle dom as first argument...
 | 
						// handle dom as first argument...
 | 
				
			||||||
	__init__: function(dom, ...args){
 | 
						__init__: function(dom, ...args){
 | 
				
			||||||
		if(typeof(Element) != 'undefined'){
 | 
							if(typeof(Element) != 'undefined'){
 | 
				
			||||||
@ -1211,8 +1208,6 @@ object.Constructor('pWikiPageElement', Page, {
 | 
				
			|||||||
				this.dom = dom
 | 
									this.dom = dom
 | 
				
			||||||
			} else {
 | 
								} else {
 | 
				
			||||||
				args.unshift(dom) } }
 | 
									args.unshift(dom) } }
 | 
				
			||||||
		// XXX is this the correct way to go???
 | 
					 | 
				
			||||||
		this.__clone_base__ = this.clone()
 | 
					 | 
				
			||||||
		return object.parentCall(pWikiPageElement.prototype.__init__, this, ...args) },
 | 
							return object.parentCall(pWikiPageElement.prototype.__init__, this, ...args) },
 | 
				
			||||||
})
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										10
									
								
								pwiki2.js
									
									
									
									
									
								
							
							
						
						
									
										10
									
								
								pwiki2.js
									
									
									
									
									
								
							@ -1,16 +1,6 @@
 | 
				
			|||||||
/**********************************************************************
 | 
					/**********************************************************************
 | 
				
			||||||
* 
 | 
					* 
 | 
				
			||||||
*
 | 
					*
 | 
				
			||||||
* XXX BUG:
 | 
					 | 
				
			||||||
* 		pwiki.get(..)					-> Page object
 | 
					 | 
				
			||||||
* 		pwiki.get(..).get(..)			-> pWikiPageElement object
 | 
					 | 
				
			||||||
* 		pwiki.get(..).get(..).get(..)	-> Page object
 | 
					 | 
				
			||||||
* 		...
 | 
					 | 
				
			||||||
* 		..the problem here is trivial, we are doing  Object.construct(this.root) 
 | 
					 | 
				
			||||||
* 		in clone -- the question is what are we going to clone if .root
 | 
					 | 
				
			||||||
* 		is of a different type (without ending up with long inheritance
 | 
					 | 
				
			||||||
* 		chains)???
 | 
					 | 
				
			||||||
*
 | 
					 | 
				
			||||||
* XXX BUG: .get('/*').raw hangs...
 | 
					* XXX BUG: .get('/*').raw hangs...
 | 
				
			||||||
* XXX add action to reset overloaded (bootstrap) pages...
 | 
					* XXX add action to reset overloaded (bootstrap) pages...
 | 
				
			||||||
* 		- per page
 | 
					* 		- per page
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user