salat 0.2.9 → 2.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,79 +1,77 @@
1
- <p align="center">
2
- <img src="images/logo.png">
3
- </p>
4
-
5
- # Salat [![npm version](https://badge.fury.io/js/salat.svg)](https://badge.fury.io/js/salat)
6
-
7
- ## Description
8
-
9
- > Daily prayer time in all the cities in [Morocco](https://www.google.com/search?q=morocco) :morocco:, directly in your terminal, at the tip of your fingers
10
-
11
-
12
- **A stupid simple Command line utility to get the daily prayers time for all the citiy in Morocco**
13
-
14
- The source of the data is [the Moroccan Ministery Website](http://www.habous.gov.ma)
15
-
16
- ## Getting started
17
-
18
- ```bash
19
- # Install
20
-
21
- $ npm i -g salat
22
-
23
- # Run with default city
24
-
25
- $ salat
26
-
27
- # Run with custom city
28
-
29
- $ salat [cityName]
30
- ```
31
-
32
- `City name should be provided the same way it's written in the cities.json`
33
-
34
- ## Output
35
-
36
- ```bash
37
- # The programs prints to the console the prayers' time for the current day in the default city as shown bellow:
38
- ```
39
- ![screen 1](images/screenShot1.png)
40
- ![screen 2](images/screenShot2.png)
41
-
42
- ## Dependecies
43
-
44
- The code behind depends on :
45
-
46
- - [axios](https://github.com/axios/axios) to make an http request ( fetch the data).
47
- - [jsdom](https://github.com/jsdom/jsdom) to parse the html result.
48
- - [chalk](https://github.com/chalk/chalk) to avoid boring styles and colors.
49
- - [node-localstorage](https://github.com/lmaccherone/node-localstorage) to read and write from localstorage.
50
-
51
- ## Change the default city
52
-
53
- - The default city is :heart: [Marrakech](https://www.google.com/search?q=marrakech) :heart:, set as a value for the `DEFAULT_CITY` variable in `./constants.js`
54
-
55
- - You can change it by replacing `Marrakech` by your city name according to the values from `./data/cities.json`
56
-
57
- ## Help
58
-
59
- - Please keep in mind that this is a work in progress in a very early stages, any help is appreciated and more than welcome.
60
-
61
- - If you think this piece of code is anyhow useful, please feel free to `contribute`, `star` :star::star: and `share` 🙏 🙏
62
-
63
- ## Todo
64
-
65
- - [x] Use a default city
66
- - [x] Use localstorage-like api for caching purposes
67
- - [x] Display execution time
68
- - [ ] Improve performance
69
- - [ ] Add unit tests
70
- - [ ] Add a documentation site
71
- - [ ] Command to set the default city
72
- - [ ] Command to display the list of available cities
73
- - [ ] Command to display the time table for the whole month
74
-
75
- ## License
76
-
77
- This project is under the MIT license.
78
-
79
- ### Built With :heart: in Ramadan
1
+ # Salat [![npm version](https://badge.fury.io/js/salat.svg)](https://badge.fury.io/js/salat)
2
+
3
+ ## Description
4
+
5
+ > Daily prayer time in all the cities in [Morocco](https://www.google.com/search?q=morocco) :morocco:, directly in your terminal, at the tip of your fingers
6
+
7
+
8
+ **A stupid simple Command line utility to get the daily prayers time for all the citiy in Morocco**
9
+
10
+ The source of the data is [the Moroccan Ministery Website](http://www.habous.gov.ma)
11
+
12
+ ## Getting started
13
+
14
+ ```bash
15
+ # Install
16
+
17
+ $ npm i -g salat
18
+
19
+ # Run with default city
20
+
21
+ $ salat
22
+
23
+ # Run with custom city
24
+
25
+ $ salat [cityName]
26
+ ```
27
+
28
+ `City name should be provided the same way it's written in the cities.json`
29
+
30
+ ## Output
31
+
32
+ ```bash
33
+ # The programs prints to the console the prayers' time for the current day in the default city as shown bellow:
34
+ ```
35
+ ![screen 1](images/screenShot1.png)
36
+ ![screen 2](images/screenShot2.png)
37
+ ![screen 3](images/screenShot3.png)
38
+
39
+
40
+ ## Dependecies
41
+
42
+ The code behind depends on :
43
+
44
+ - [axios](https://github.com/axios/axios) to make an http request ( fetch the data).
45
+ - [jsdom](https://github.com/jsdom/jsdom) to parse the html result.
46
+ - [chalk](https://github.com/chalk/chalk) to avoid boring styles and colors.
47
+ - [node-localstorage](https://github.com/lmaccherone/node-localstorage) to read and write from localstorage.
48
+
49
+ ## Change the default city
50
+
51
+ - The default city is :heart: [Marrakech](https://www.google.com/search?q=marrakech) :heart:, set as a value for the `DEFAULT_CITY` variable in `./constants.js`
52
+
53
+ - You can change it by replacing `Marrakech` by your city name according to the values from `./data/cities.json`
54
+
55
+ ## Help
56
+
57
+ - Please keep in mind that this is a work in progress in a very early stages, any help is appreciated and more than welcome.
58
+
59
+ - If you think this piece of code is anyhow useful, please feel free to `contribute`, `star` :star::star: and `share` 🙏 🙏
60
+
61
+ ## Todo
62
+
63
+ - [x] Use a default city
64
+ - [x] Use localstorage-like api for caching purposes
65
+ - [x] Display execution time
66
+ - [ ] Improve performance
67
+ - [ ] Add unit tests
68
+ - [ ] Add a documentation site
69
+ - [ ] Command to set the default city
70
+ - [ ] Command to display the list of available cities
71
+ - [ ] Command to display the time table for the whole month
72
+
73
+ ## License
74
+
75
+ This project is under the MIT license.
76
+
77
+ ### Built With :heart: in Ramadan
package/_config.yml CHANGED
@@ -1 +1 @@
1
- theme: jekyll-theme-slate
1
+ theme: jekyll-theme-cayman
@@ -1,57 +1,57 @@
1
- #!/usr/bin/env node
2
-
3
- // Project's dependencies
4
- const chalk = require("chalk");
5
- const args = process.argv;
6
- const {
7
- getCityId,
8
- getCityName,
9
- displayResult,
10
- getData,
11
- parsePrayerTimesFromResponse
12
- } = require("./utils.js");
13
-
14
- // Logging functioin
15
- const green = msg => console.log(chalk.green(msg));
16
-
17
- // Project's data
18
- const { BANNER, LOCAL_STORAGE_PATH } = require("./constants");
19
- const cities = require("./data/cities.json");
20
-
21
- // Setting up localStorage
22
- const { LocalStorage } = require("node-localstorage");
23
- localStorage = new LocalStorage(LOCAL_STORAGE_PATH);
24
-
25
- const cityName = getCityName(args[2], cities);
26
- const cityId = getCityId(cityName, cities);
27
-
28
- const main = async () => {
29
- // Prinitng a banner ('cause I'm cool and I can do it XD)
30
- green(BANNER);
31
-
32
- const storageKey = `${cityName.toLowerCase()}_${new Date().toLocaleDateString()}`;
33
- const item = localStorage.getItem(storageKey);
34
- let prayers;
35
-
36
- if (item) {
37
- prayers = JSON.parse(item);
38
- } else {
39
- try {
40
- prayers = parsePrayerTimesFromResponse(await getData(cityId));
41
- localStorage.setItem(storageKey, JSON.stringify(prayers));
42
- } catch (ex) {
43
- //TODO: Use a more descriptif error message
44
- console.error("Someting bad happened");
45
- // console.log(ex);
46
- return;
47
- }
48
- }
49
-
50
- displayResult(prayers, cityName);
51
- };
52
-
53
- (async () => {
54
- console.time("Execution Time");
55
- await main();
56
- console.timeEnd("Execution Time");
57
- })();
1
+ #!/usr/bin/env node
2
+
3
+ // Project's dependencies
4
+ const chalk = require("chalk");
5
+ const args = process.argv;
6
+ const {
7
+ getCityId,
8
+ getCityName,
9
+ displayResult,
10
+ getData,
11
+ parsePrayerTimesFromResponse
12
+ } = require("./utils.js");
13
+ process.env.NODE_TLS_REJECT_UNAUTHORIZED="0"
14
+
15
+ // Logging functioin
16
+ const green = msg => console.log(chalk.green(msg));
17
+
18
+ // Project's data
19
+ const { BANNER, LOCAL_STORAGE_PATH } = require("./constants");
20
+ const cities = require("./data/cities.json");
21
+
22
+ // Setting up localStorage
23
+ const { LocalStorage } = require("node-localstorage");
24
+ localStorage = new LocalStorage(LOCAL_STORAGE_PATH);
25
+
26
+ const cityName = getCityName(args[2], cities);
27
+ const cityId = getCityId(cityName, cities);
28
+
29
+ const main = async () => {
30
+ // Prinitng a banner ('cause I'm cool and I can do it XD)
31
+ green(BANNER);
32
+
33
+ const storageKey = `${cityName.toLowerCase()}_${new Date().toLocaleDateString()}`;
34
+ const item = localStorage.getItem(storageKey);
35
+ let prayers;
36
+
37
+ if (item) {
38
+ prayers = JSON.parse(item);
39
+ } else {
40
+ try {
41
+ prayers = parsePrayerTimesFromResponse(await getData(cityId));
42
+ localStorage.setItem(storageKey, JSON.stringify(prayers));
43
+ } catch (ex) {
44
+ //TODO: Use a more descriptif error message
45
+ console.error("Something went wrong!");
46
+ console.log(ex)
47
+ // console.log(ex);
48
+ return;
49
+ }
50
+ }
51
+
52
+ displayResult(prayers, cityName);
53
+ };
54
+
55
+ (async () => {
56
+ await main();
57
+ })();
package/constants.js CHANGED
@@ -1,32 +1,19 @@
1
- const API_URL =
2
- "http://www.habous.gov.ma/horaire%20de%20priere/horaire-pub.php";
3
-
4
- const BANNER = `
5
- _______ _______ ___ _______ _______
6
- | || _ || | | _ || |
7
- | _____|| | | || | | | | ||_ _|
8
- | |_____ | |_| || | | |_| | | |
9
- |_____ || || |___ | | | |
10
- _____| || _ || || _ | | |
11
- |_______||__| |__||_______||__| |__| |___| v.${
12
- require("./package.json").version
13
- }
14
- ------------------------------------------- by ${
15
- require("./package.json").author.name
16
- }
17
- `;
18
-
19
- const NOT_FOUND_ERROR = `
20
- Your city was not found in the list
21
- Using the default city
22
- ----------------------
23
- You may need to check the spelling
24
- `;
25
-
26
- module.exports = {
27
- API_URL,
28
- BANNER,
29
- NOT_FOUND_ERROR,
30
- DEFAULT_CITY: "Marrakech",
31
- LOCAL_STORAGE_PATH: "./storage"
32
- };
1
+ const API_URL =
2
+ "http://www.habous.gov.ma/prieres/horaire-api.php";
3
+
4
+ const BANNER = ``;
5
+
6
+ const NOT_FOUND_ERROR = `
7
+ Your city was not found in the list
8
+ Using the default city
9
+ ----------------------
10
+ You may need to check the spelling
11
+ `;
12
+
13
+ module.exports = {
14
+ API_URL,
15
+ BANNER,
16
+ NOT_FOUND_ERROR,
17
+ DEFAULT_CITY: "Marrakech",
18
+ LOCAL_STORAGE_PATH: "./storage"
19
+ };