Skip to content

Commit

Permalink
first commit :)
Browse files Browse the repository at this point in the history
  • Loading branch information
arastu committed Jun 4, 2015
1 parent 098be59 commit a9fabc0
Show file tree
Hide file tree
Showing 42 changed files with 25,662 additions and 2 deletions.
26 changes: 24 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,24 @@
# administrative_divisions_of_Iran
Administrative divisions of Iran in json format - تقصیمات کشوری ایران با فرمت جی‌سان
[![NPM](https://nodei.co/npm/iran.png?downloads=true&downloadRank=true&stars=true)](https://nodei.co/npm/iran/)

# Administrative divisions of Iran
##List of Iran cities in json and xml format based on administrative divisions of Iran.
sources: Pars html tables at [http://portal2.moi.ir/Portal/Home/Default.aspx?CategoryID=8f931308-c67e-4cf4-a5e7-3c1bbb1a6f32](http://portal2.moi.ir/Portal/Home/Default.aspx?CategoryID=8f931308-c67e-4cf4-a5e7-3c1bbb1a6f32)

On the first level of country subdivisions of Iran are the provinces.
Each province is further subdivided into counties called shahrestan (Persian: شهرستان shahrestān‎), and each shahrestan is subdivided into districts called bakhsh (Persian: بخش bakhsh‎). There are usually a few cities (Persian: شهر shahr‎) in each county.

#Downloads (Right-click, and use "Save As")

Version 0.0.1 [Source code (zip)](https://github.com/arastu/iran-administrative-divisions/archive/0.0.1.zip)

Version 0.0.1 [Source code (tar.gz)](https://github.com/arastu/iran-administrative-divisions/archive/0.0.1.tar.gz)

#Installation

```Node.js npm install iran```

```Require.js require([“iran”], ...```

```Bower bower install iran```

```Angular.js angular.module('yourApp', [‘iran’])…```
28 changes: 28 additions & 0 deletions bower.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"name": "iran",
"version": "0.0.1",
"homepage": "https://github.com/arastu/iran-administrative-divisions",
"authors": [
"Touhid Arastu <[email protected]> (http://arastu.ir/)"
],
"description": "List of Iran cities in json and xml format based on administrative divisions of Iran.",
"main": "dist/iran.js",
"keywords": [
"iran",
"administrative divisions",
"countries",
"world",
"json",
"xml",
"persian",
"farsi"
],
"license": "MIT",
"ignore": [
"**/.*",
"node_modules",
"bower_components",
"test",
"tests"
]
}
89 changes: 89 additions & 0 deletions builder.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
var fs = require('fs');
var parser = require('./lib/parser.js');
var js2xmlparser = require("js2xmlparser");

fs.readFile('./iran_administrative_divisions_json.html', 'utf8', function read(err, data) {
if (err) {
throw err;
} else {
//convert html string to javascript object
var data = parser.pars(data);

var json = JSON.stringify(data, null, 2);
var xml = JSON.stringify({'city':data});

var javascript = '(function () {' + '\n' +
'\t// Establish the root object, `window` in the browser, or `exports` on the server.' + '\n' +
'\tvar root = this;' + '\n' +
'\n' +
'\t// Create a safe reference to the iran object for use below.' + '\n' +
'\tvar iran = function (obj) {' + '\n' +
'\t\tif (obj instanceof iran) return obj;' + '\n' +
'\t\tif (!(this instanceof iran)) return new iran(obj);' + '\n' +
'\t\tthis._wrapped = obj;' + '\n' +
'\t};' + '\n' +
'\n' +
'\t// Export the iran object for **Node.js**, with' + '\n' +
'\t// backwards-compatibility for the old `require()` API. If we\'re in' + '\n' +
'\t// the browser, add `iran` as a global object.' + '\n' +
'\tif (typeof exports !== \'undefined\') {' + '\n' +
'\t\tif (typeof module !== \'undefined\' && module.exports) {' + '\n' +
'\t\t\texports = module.exports = iran;' + '\n' +
'\t\t}' + '\n' +
'\t\texports.iran = iran;' + '\n' +
'\t} else {' + '\n' +
'\t\troot.iran = iran;' + '\n' +
'\t}' + '\n' +
'\n' +
'\t// Current version.' + '\n' +
'\tiran.VERSION = \'0.0.1\';' + '\n' +
'\n' +
'\tiran.cities = JSON.parse(\'' + JSON.stringify(data) + '\')' + '\n' +
'\n' +
'\n' +
'\t// Register iran angular module' + '\n' +
'\t// iran service avilable' + '\n' +
'\tif (typeof angular === \'object\') {' + '\n' +
'\t\tangular.module(\'iran\', [])' + '\n' +
'\t\t.service(\'iran\', function () {' + '\n' +
'\t\t\treturn iran;' + '\n' +
'\t\t});' + '\n' +
'\t}' + '\n' +
'\n' +
'\t// AMD registration happens at the end for compatibility with AMD loaders' + '\n' +
'\t// that may not enforce next-turn semantics on modules. Even though general' + '\n' +
'\t// practice for AMD registration is to be anonymous, iran registers' + '\n' +
'\t// as a named module because, like jQuery, it is a base library that is' + '\n' +
'\t// popular enough to be bundled in a third party lib, but not be part of' + '\n' +
'\t// an AMD load request. Those cases could generate an error when an' + '\n' +
'\t// anonymous define() is called outside of a loader request.' + '\n' +
'\tif (typeof define === \'function\' && define.amd) {' + '\n' +
'\t\tdefine(\'iran\', [], function() {' + '\n' +
'\t\t\treturn iran;' + '\n' +
'\t\t});' + '\n' +
'\t}' + '\n' +
'}.call(this));';


fs.writeFile('./dist/iran.json', json, function (err) {
if (err) {
throw err;
}
console.log('iran.json saved!');
});

fs.writeFile('./dist/iran.js', javascript, function (err) {
if (err) {
throw err;
}
console.log('iran.js saved!');
});

fs.writeFile('./dist/iran.xml', js2xmlparser('iran', xml), function (err) {
if (err) {
throw err;
}
console.log('iran.xml saved!');
});
}
});
51 changes: 51 additions & 0 deletions dist/iran.js

Large diffs are not rendered by default.

Loading

0 comments on commit a9fabc0

Please sign in to comment.