Add nya filter
This commit is contained in:
		
							parent
							
								
									17bc0d4844
								
							
						
					
					
						commit
						f844a47f1d
					
				
					 4 changed files with 27 additions and 1 deletions
				
			
		|  | @ -22,6 +22,7 @@ module.exports = ~> | ||||||
| 	data = | 	data = | ||||||
| 		cache: true | 		cache: true | ||||||
| 		debug: false | 		debug: false | ||||||
|  | 		nya: true | ||||||
| 		home: home-data | 		home: home-data | ||||||
| 
 | 
 | ||||||
| 	return data | 	return data | ||||||
|  |  | ||||||
|  | @ -14,3 +14,5 @@ module.exports = (me) -> | ||||||
| 			if data? | 			if data? | ||||||
| 				Object.assign me, data | 				Object.assign me, data | ||||||
| 			me.trigger \updated | 			me.trigger \updated | ||||||
|  | 
 | ||||||
|  | 		me: me | ||||||
|  |  | ||||||
|  | @ -1,3 +1,5 @@ | ||||||
|  | const riot = require('riot'); | ||||||
|  | 
 | ||||||
| module.exports = function(tokens, canBreak, escape) { | module.exports = function(tokens, canBreak, escape) { | ||||||
| 	if (canBreak == null) { | 	if (canBreak == null) { | ||||||
| 		canBreak = true; | 		canBreak = true; | ||||||
|  | @ -5,7 +7,10 @@ module.exports = function(tokens, canBreak, escape) { | ||||||
| 	if (escape == null) { | 	if (escape == null) { | ||||||
| 		escape = true; | 		escape = true; | ||||||
| 	} | 	} | ||||||
| 	return tokens.map(function(token) { | 
 | ||||||
|  | 	const me = riot.mixin('i').me; | ||||||
|  | 
 | ||||||
|  | 	let text = tokens.map(function(token) { | ||||||
| 		switch (token.type) { | 		switch (token.type) { | ||||||
| 			case 'text': | 			case 'text': | ||||||
| 				if (escape) { | 				if (escape) { | ||||||
|  | @ -27,4 +32,10 @@ module.exports = function(tokens, canBreak, escape) { | ||||||
| 				return '<a>' + token.content + '</a>'; | 				return '<a>' + token.content + '</a>'; | ||||||
| 		} | 		} | ||||||
| 	}).join(''); | 	}).join(''); | ||||||
|  | 
 | ||||||
|  | 	if (me && me.data && me.data.nya) { | ||||||
|  | 		text = text.replace(/な/g, 'にゃ'); | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  | 	return text; | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -58,6 +58,10 @@ mk-settings | ||||||
| 				input(type='checkbox', checked={ I.data.debug }, onclick={ update-debug }) | 				input(type='checkbox', checked={ I.data.debug }, onclick={ update-debug }) | ||||||
| 				p 開発者モード | 				p 開発者モード | ||||||
| 				p デバッグ等の開発者モードを有効にします。 | 				p デバッグ等の開発者モードを有効にします。 | ||||||
|  | 			label.checkbox | ||||||
|  | 				input(type='checkbox', checked={ I.data.nya }, onclick={ update-nya }) | ||||||
|  | 				p <i>な</i>を<i>にゃ</i>に変換する | ||||||
|  | 				p 攻撃的な投稿が多少和らぐ可能性があります。 | ||||||
| 
 | 
 | ||||||
| 		section.signin(show={ page == 'signin' }) | 		section.signin(show={ page == 'signin' }) | ||||||
| 			h1 ログイン履歴 | 			h1 ログイン履歴 | ||||||
|  | @ -253,3 +257,11 @@ script. | ||||||
| 				debug: @I.data.debug | 				debug: @I.data.debug | ||||||
| 		.then ~> | 		.then ~> | ||||||
| 			@update-i! | 			@update-i! | ||||||
|  | 
 | ||||||
|  | 	@update-nya = ~> | ||||||
|  | 		@I.data.nya = !@I.data.nya | ||||||
|  | 		@api \i/appdata/set do | ||||||
|  | 			data: JSON.stringify do | ||||||
|  | 				nya: @I.data.nya | ||||||
|  | 		.then ~> | ||||||
|  | 			@update-i! | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue