コンテンツにスキップ

英文维基 | 中文维基 | 日文维基 | 草榴社区

モジュール:NVR/rules

モジュールの解説[作成]
local p = {}

-- rules for transforming links to a ship in the Naval Vessel Register
p.ShipRules = {
	urls = {
		['old'] = 'http://www.nvr.navy.mil/NVRSHIPS/DETAILS/****.HTM',
		['new'] = 'http://www.nvr.navy.mil/SHIPDETAILS/SHIPSDETAIL_****.HTML',
	},
	rules = {
		{
			method = 'literal',
			match = 'MAINE',
			replace = '939',
			url = 'new',
		},
		{
			method = 'literal',
			match = 'MARCOS',
			replace = '940',
			url = 'new',
		},
		{
			method = 'literal',
			match = 'OLDIRON',
			replace = '1315',
			url = 'new',
		},
		{
			method = 'literal',
			match = 'AFSB15',
			replace = 'AFSB_(I)_15',
			url = 'new',
		},
		{
			method = 'pattern',
			match = '^[A-Z]+[0-9]+$',
			pattern = '^([A-Z]+)([0-9]+)$',
			replace = '%1_%2',
			url = 'new',
		},
		{
			method = 'all',
			url = 'new',
		},
	}
}

-- rules for transforming links to a service craft in the Naval Vessel Register
p.ServiceCraftRules = {
	urls = {
		['old'] = 'http://www.nvr.navy.mil/NVRSERVICECRAFT/DETAILS/****.HTM',
		['new'] = 'http://www.nvr.navy.mil/SHIPDETAILS/SHIPSDETAIL_****.HTML',
	},
	rules = {
		{
			method = 'literal',
			match = 'AFDB7_1',
			replace = 'AFDB_7',
			url = 'new',
		},
		{
			method = 'literal',
			match = 'AFDB1_1',
			url = 'old',
		},
		{
			method = 'literal',
			match = 'AFDB1_3',
			url = 'old',
		},
		{
			method = 'literal',
			match = 'AFDB1_4',
			url = 'old',
		},
		{
			method = 'literal',
			match = 'AFDB7_2',
			url = 'old',
		},
		{
			method = 'pattern',
			match = '^[A-Z]+[0-9]+$',
			pattern = '^([A-Z]+)([0-9]+)$',
			replace = '%1_%2',
			url = 'new',
		},
		{
			method = 'all',
			url = 'new',
		},
	}
}
 
 
return p