Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mdecker-mobilecomputing/angular_chucknorrisfacts
Angular application acting as client for REST-API provided by icndb.com.
https://github.com/mdecker-mobilecomputing/angular_chucknorrisfacts
angular bootstrap chuck-norris-facts chuck-norris-jokes gh-pages rest-client
Last synced: 5 days ago
JSON representation
Angular application acting as client for REST-API provided by icndb.com.
- Host: GitHub
- URL: https://github.com/mdecker-mobilecomputing/angular_chucknorrisfacts
- Owner: MDecker-MobileComputing
- License: gpl-3.0
- Created: 2020-04-04T22:19:26.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2024-03-28T16:22:02.000Z (8 months ago)
- Last Synced: 2024-04-13T23:08:57.862Z (7 months ago)
- Topics: angular, bootstrap, chuck-norris-facts, chuck-norris-jokes, gh-pages, rest-client
- Language: TypeScript
- Homepage:
- Size: 3.3 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# Angular application to fetch Chuck Norris facts from icndb.com #
**Not working anymore, because Web-API `icndb.com` was disbled?**
Simple [Angular](https://angular.io) application to fetch so called [Chuck Norris facts](https://en.wikipedia.org/wiki/Chuck_Norris_facts) (short jokes)
from the REST-API provided by [icndb.com](http://www.icndb.com/).You can try out the application directly [**here**](https://mdecker-mobilecomputing.github.io/Angular_ChuckNorrisFacts/) via *GitHub Pages*.
----
## References ##
* [Description of REST-API provided by ICNDB](http://www.icndb.com/api/)
* File [ExampleResponseFromRestAPI.json](./ExampleResponseFromRestAPI.json) with an example for an response from the
REST-API when request asked to return 5 random jokes.
* [Article on "Chuck Norris facts" on Wikipedia](https://en.wikipedia.org/wiki/Chuck_Norris_facts)
* [Tutorial on HTTP-GET requests in an Angular application](https://www.ahmedbouchefra.com/angular/angular-9-8-example-import-httpclientmodule-and-send-http-ajax-requests/)
* [Video "Chuck Norris facts read by Chuck Norris" on youtube.com](https://www.youtube.com/watch?v=kQmPMZeN7JQ)
* Similar API: https://api.chucknorris.io/
----
## Building the application ##
Execute command `npm run build` to build the application.
The target folder for output of command `ng build` was moved to folder [docs](docs/) to enable serving of the generated application via [GitHub Pages](https://pages.github.com/), see key `architect/build/options/outputPath` in file [angular.json](angular.json).
The application has a [Web App Manifest](https://web.dev/add-manifest/), see file [src/manifest.json](src/manifest.json).
This manifest is declared in file [angular.json](angular.json) in the array `projects/architect/assets`, so
it is also copied to the target folder [docs](docs/).
This manifest file is referenced by a `` in file [src/index.html](src/index.html).
The *Web App Manifest* can be checked in Chome und Chrome-based browsers like Opera in the *Developer Tools* under "Application | Manifest",
see [this screenshot](screenshots/screenshot_CheckApplicationManifest.png).
----
## Internals ##
The actual loading of the jokes from the REST-API via HTTP is implemented in service class [icndb.service.ts](src/app/icndb.service.ts).
The jokes are not fetched individually, but in batches which are stored in an internal array that acts as queue.For styling the [bootstrap](https://getbootstrap.com) framework is used.
This Angular application can access the REST-API from a different domains than it is served itself because the
HTTP response from the REST-API contains the HTTP header `Access-Control-Allow-Origin: *`.
This HTTP header tells most browsers to not block the Ajax request made by this application despite its
violation of the *Same Origin Policy*.The favorites are stored in the browser's *Local Storage*, i.e. stored favorites are available only in the browser installation that was used to save them.
The favorites in the *Local Storage* can be checked in the browser's developer tools;
for example, in Chrome und Chrome-based browsers like Opera you have to open the
*Developer Tools* and navigate to "Application | Local Storage", see
[this screenshot](screenshots/screenshot_CheckLocalStorage.png).
----
## License ##
See the [LICENSE file](LICENSE.md) for license rights and limitations (GPL v3) for the files in this repository.
The author of this application is *NEITHER* related to [The Internet Chuck Norris Database (icndb.com)](http://www.icndb.com/) *NOR* to Chuck Norris.