mirror of
				https://github.com/flynx/pWiki.git
				synced 2025-10-31 02:50:08 +00:00 
			
		
		
		
	closed most of the wiki engine features, still several bugs to squash...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
		
							parent
							
								
									7c35da904a
								
							
						
					
					
						commit
						94d65f6064
					
				
							
								
								
									
										69
									
								
								pwiki2.js
									
									
									
									
									
								
							
							
						
						
									
										69
									
								
								pwiki2.js
									
									
									
									
									
								
							| @ -131,6 +131,9 @@ module.path = { | |||||||
| 					if(tpl[0] == '/'){ | 					if(tpl[0] == '/'){ | ||||||
| 						break } | 						break } | ||||||
| 					p.pop() } } } }, | 					p.pop() } } } }, | ||||||
|  | 
 | ||||||
|  | 	split: function(path){ | ||||||
|  | 		return this.normalize(path, 'array') }, | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| @ -139,6 +142,7 @@ module.path = { | |||||||
| 
 | 
 | ||||||
| // NOTE: store keys must be normalized...
 | // NOTE: store keys must be normalized...
 | ||||||
| //
 | //
 | ||||||
|  | // XXX BUG: mixing up '/' and '' paths...
 | ||||||
| // XXX LEADING_SLASH should this be strict about leading '/' in paths???
 | // XXX LEADING_SLASH should this be strict about leading '/' in paths???
 | ||||||
| // 		...this may lead to duplicate paths created -- '/a/b' and 'a/b'
 | // 		...this may lead to duplicate paths created -- '/a/b' and 'a/b'
 | ||||||
| // XXX would be nice to be able to create sub-stores, i.e. an object that
 | // XXX would be nice to be able to create sub-stores, i.e. an object that
 | ||||||
| @ -147,8 +151,8 @@ module.path = { | |||||||
| // XXX must support store stacks...
 | // XXX must support store stacks...
 | ||||||
| // XXX path macros???
 | // XXX path macros???
 | ||||||
| // XXX should we support page symlinking???
 | // XXX should we support page symlinking???
 | ||||||
| var store =  | var BaseStore =  | ||||||
| module.store = { | module.BaseStore = { | ||||||
| 	exists: function(path){ | 	exists: function(path){ | ||||||
| 		path = module.path.normalize(path, 'string') | 		path = module.path.normalize(path, 'string') | ||||||
| 		return path in this | 		return path in this | ||||||
| @ -282,17 +286,31 @@ module.store = { | |||||||
| 
 | 
 | ||||||
| // XXX need to specify page format....
 | // XXX need to specify page format....
 | ||||||
| // XXX need a way to set the page path...
 | // XXX need a way to set the page path...
 | ||||||
| var actions =  | var store =  | ||||||
| module.actions = { | module.store = { | ||||||
| 	__proto__: store, | 	__proto__: BaseStore, | ||||||
| 
 | 
 | ||||||
| 	// base actions (virtual pages)...
 | 	// base actions (virtual pages)...
 | ||||||
| 	'System/raw': function(page, path){ | 	'System/path': function(page){ | ||||||
| 		return { text: this.get(path +'/..') } }, | 		return this.get('..').path }, | ||||||
| 	// XXX ...
 | 	'System/dir': function(page){ | ||||||
|  | 		return this.get('..').dir }, | ||||||
|  | 	'System/name': function(page){ | ||||||
|  | 		return this.get('..').name }, | ||||||
|  | 
 | ||||||
|  | 	'System/title': function(page){ | ||||||
|  | 		var p = this.get('..') | ||||||
|  | 		return p.title  | ||||||
|  | 			?? p.name }, | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 	// XXX other things to do...
 | ||||||
|  | 	// 		- title
 | ||||||
|  | 	//
 | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|  | 
 | ||||||
| // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
 | ||||||
| 
 | 
 | ||||||
| var relProxy =  | var relProxy =  | ||||||
| @ -344,6 +362,13 @@ object.Constructor('BasePage', { | |||||||
| 	set path(value){ | 	set path(value){ | ||||||
| 		this.location = value }, | 		this.location = value }, | ||||||
| 
 | 
 | ||||||
|  | 	get name(){ | ||||||
|  | 		return module.path.split(this.path).pop() }, | ||||||
|  | 	// XXX should this rename or change path???
 | ||||||
|  | 	//set name(value){ },
 | ||||||
|  | 	get dir(){ | ||||||
|  | 		return module.path.relative(this.location, '..') }, | ||||||
|  | 
 | ||||||
| 	//* XXX HISTORY...
 | 	//* XXX HISTORY...
 | ||||||
| 	// NOTE: set this to false to disable history...
 | 	// NOTE: set this to false to disable history...
 | ||||||
| 	__history: undefined, | 	__history: undefined, | ||||||
| @ -497,7 +522,6 @@ object.Constructor('BasePage', { | |||||||
| //---------------------------------------------------------------------
 | //---------------------------------------------------------------------
 | ||||||
| // Parser...
 | // Parser...
 | ||||||
| 
 | 
 | ||||||
| 
 |  | ||||||
| // XXX should we warn about stuff like <macro src=/moo/> -- currently 
 | // XXX should we warn about stuff like <macro src=/moo/> -- currently 
 | ||||||
| // 		this will simply be ignored, i.e. passed trough the parser 
 | // 		this will simply be ignored, i.e. passed trough the parser 
 | ||||||
| // 		without change...
 | // 		without change...
 | ||||||
| @ -767,7 +791,7 @@ module.BaseParser = { | |||||||
| 			: lex | 			: lex | ||||||
| 
 | 
 | ||||||
| 		var quoting = to  | 		var quoting = to  | ||||||
| 			&& page.QUOTING_MACROS.includes(to) | 			&& (page.QUOTING_MACROS ?? []).includes(to) | ||||||
| 			&& [] | 			&& [] | ||||||
| 
 | 
 | ||||||
| 		// NOTE: we are not using for .. of .. here as it depletes the 
 | 		// NOTE: we are not using for .. of .. here as it depletes the 
 | ||||||
| @ -922,6 +946,8 @@ module.parser = { | |||||||
| } | } | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|  | // -  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
 | ||||||
|  | 
 | ||||||
| // XXX revise...
 | // XXX revise...
 | ||||||
| var Filter =  | var Filter =  | ||||||
| module.Filter = | module.Filter = | ||||||
| @ -932,14 +958,17 @@ function(...args){ | |||||||
| 	return func } | 	return func } | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|  | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
 | ||||||
|  | 
 | ||||||
| // XXX PATH_VARS need to handle path variables...
 | // XXX PATH_VARS need to handle path variables...
 | ||||||
| // XXX macros and filters should be features for simpler plugin handlng (???)
 | // XXX macros and filters should be features for simpler plugin handlng (???)
 | ||||||
| var Page = | var Page = | ||||||
| module.Page =  | module.Page =  | ||||||
| object.Constructor('Page', BasePage, { | object.Constructor('Page', BasePage, { | ||||||
| 	//NO_FILTERS: 'nofilters',
 | 	// Filter that will isolate the page/include/.. from parent filters...
 | ||||||
| 	ISOLATED_FILTERS: 'isolated', | 	ISOLATED_FILTERS: 'isolated', | ||||||
| 
 | 
 | ||||||
|  | 	// list of macros that will get raw text of their content...
 | ||||||
| 	QUOTING_MACROS: ['quote'], | 	QUOTING_MACROS: ['quote'], | ||||||
| 
 | 
 | ||||||
| 	//
 | 	//
 | ||||||
| @ -977,6 +1006,15 @@ object.Constructor('Page', BasePage, { | |||||||
| 			return source }, | 			return source }, | ||||||
| 	}, | 	}, | ||||||
| 
 | 
 | ||||||
|  | 	//
 | ||||||
|  | 	// 	<macro>(<args>, <body>, <state>){ .. }
 | ||||||
|  | 	// 		-> undefined
 | ||||||
|  | 	// 		-> <text>
 | ||||||
|  | 	// 		-> <array>
 | ||||||
|  | 	// 		-> <iterator>
 | ||||||
|  | 	// 		-> <func>(<state>)
 | ||||||
|  | 	// 			-> ...
 | ||||||
|  | 	//
 | ||||||
| 	// XXX need a good way to get the first positional arg without 
 | 	// XXX need a good way to get the first positional arg without 
 | ||||||
| 	// 		mixing it up with other args -- see src/name args below...
 | 	// 		mixing it up with other args -- see src/name args below...
 | ||||||
| 	macros: { | 	macros: { | ||||||
| @ -1008,7 +1046,6 @@ object.Constructor('Page', BasePage, { | |||||||
| 		// 		<filter> <filter-spec>
 | 		// 		<filter> <filter-spec>
 | ||||||
| 		// 		| -<filter> <filter-spec>
 | 		// 		| -<filter> <filter-spec>
 | ||||||
| 		//
 | 		//
 | ||||||
| 		// XXX support .NO_FILTERS ...
 |  | ||||||
| 		filter: function(args, body, state, expand=true){ | 		filter: function(args, body, state, expand=true){ | ||||||
| 			var that = this | 			var that = this | ||||||
| 			var filters = state.filters =  | 			var filters = state.filters =  | ||||||
| @ -1026,7 +1063,7 @@ object.Constructor('Page', BasePage, { | |||||||
| 			// trigger quote-filter...
 | 			// trigger quote-filter...
 | ||||||
| 			var quote = local | 			var quote = local | ||||||
| 				.map(function(filter){ | 				.map(function(filter){ | ||||||
| 					return that.filters[filter]['quote'] ?? [] }) | 					return (that.filters[filter] ?? {})['quote'] ?? [] }) | ||||||
| 				.flat() | 				.flat() | ||||||
| 			quote.length > 0 | 			quote.length > 0 | ||||||
| 				&& this.macros['quote-filter'] | 				&& this.macros['quote-filter'] | ||||||
| @ -1311,7 +1348,9 @@ object.Constructor('Page', BasePage, { | |||||||
| 	//
 | 	//
 | ||||||
| 	__parser__: module.parser, | 	__parser__: module.parser, | ||||||
| 	parse: function(state={}){ | 	parse: function(state={}){ | ||||||
| 		return this.__parser__.parse(this, null, state) }, | 		// NOTE: we do not need to pass this.raw here but it is still 
 | ||||||
|  | 		// 		here for illustration...
 | ||||||
|  | 		return this.__parser__.parse(this, this.raw, state) }, | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| 	// raw page text...
 | 	// raw page text...
 | ||||||
| @ -1323,7 +1362,7 @@ object.Constructor('Page', BasePage, { | |||||||
| 		var data = this.data | 		var data = this.data | ||||||
| 		return data instanceof Function ? | 		return data instanceof Function ? | ||||||
| 			// XXX FUNC not sure about this...
 | 			// XXX FUNC not sure about this...
 | ||||||
| 			data.call(this, 'text') | 			data.call(this) | ||||||
|    			: data.text	}, |    			: data.text	}, | ||||||
| 	set raw(value){ | 	set raw(value){ | ||||||
| 		this.store.update(this.location, {text: value}) }, | 		this.store.update(this.location, {text: value}) }, | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user