From: Michael Tremer Date: Sun, 31 Mar 2024 19:51:53 +0000 (+0000) Subject: location: Split the "How To Use?" page into several pages X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d9e4d7b2bc63302fd2bfd0dfe2c44890ab1f077b;p=ipfire.org.git location: Split the "How To Use?" page into several pages Signed-off-by: Michael Tremer --- diff --git a/Makefile.am b/Makefile.am index cde0a0b2..fa2cfc2a 100644 --- a/Makefile.am +++ b/Makefile.am @@ -269,7 +269,9 @@ templates_location_DATA = \ templates_locationdir = $(templatesdir)/location templates_location_how_to_use_DATA = \ - src/templates/location/how-to-use/index.html + src/templates/location/how-to-use/cli.html \ + src/templates/location/how-to-use/index.html \ + src/templates/location/how-to-use/python.html templates_location_how_to_usedir = $(templates_locationdir)/how-to-use diff --git a/src/templates/location/how-to-use/cli.html b/src/templates/location/how-to-use/cli.html new file mode 100644 index 00000000..03568c9b --- /dev/null +++ b/src/templates/location/how-to-use/cli.html @@ -0,0 +1,86 @@ +{% extends "../../base.html" %} + +{% block title %}{{ _("How To Use?") }} - {{ _("Command Line") }}{% end block %} + +{% block container %} +
+ +
+ +
+
+
+
+
+

+ libloc comes with a command line tool which + makes it easy to test the library or integrate it into + your shell scripts. + location(8) knows a couple of commands + to retrieve country or Autonomous System of an IP address + and can generate lists of networks to be imported into + other software. +

+ +

+ Although this is not the fastest way to lookup a large number + of IP addresses, location(8) is versatile + and very easy to use. +

+ + + {{ _("Man Page") }} + +
+
+ +
+
+ {{ _( +
+
+
+ +
+
{{ _("Search for an Autonomous System by Name") }}
+ +
$ location search-as "Lightning Wire Labs"
+AS204867 (Lightning Wire Labs GmbH)
+
+ +
+
{{ _("Lookup an IP Address") }}
+ +
$ location lookup 81.3.27.38
+81.3.27.38 belongs to 81.3.27.0/24 which is a part of AS24679 (Hostway Deutschland GmbH)
+
+
+
+{% end block %} diff --git a/src/templates/location/how-to-use/index.html b/src/templates/location/how-to-use/index.html index e5002332..97e1eed1 100644 --- a/src/templates/location/how-to-use/index.html +++ b/src/templates/location/how-to-use/index.html @@ -3,7 +3,7 @@ {% block title %}{{ _("How To Use?") }}{% end block %} {% block container %} -
+
-

{{ _("IPFire Location") }}

-
- libloc is versatile, fast and easy to use - in any application. -
+

{{ _("How To Use?") }}

-
-
-

{{ _("Command Line") }}

+

+ The heart of the IPFire Location project is a small, lightweight library + called libloc. -

-

- libloc comes with a command line tool which - makes it easy to test the library or integrate it into - your shell scripts. - location(8) knows a couple of commands - to retrieve country or Autonomous System of an IP address - and can generate lists of networks to be imported into - other software. -

- -

- Although this is not the fastest way to lookup a large number - of IP addresses, location(8) is versatile - and very easy to use. -

- - - {{ _("Man Page") }} - -
-
- -
-
- {{ _( -
-
-
- -
-
{{ _("Search for an Autonomous System by Name") }}
- -
$ location search-as "Lightning Wire Labs"
-AS204867 (Lightning Wire Labs GmbH)
-
- -
-
{{ _("Lookup an IP Address") }}
- -
$ location lookup 81.3.27.38
-81.3.27.38 belongs to 81.3.27.0/24 which is a part of AS24679 (Hostway Deutschland GmbH)
-
+ It sources the data, builds and reads the database. +

-
-
-
- {{ _( -
-
- -
-

{{ _("Python") }}

- -
-

- libloc comes with native Python bindings which - are used by its main command-line tool - - location - . - They are the most advanced bindings as they support reading - from the database as well as writing to it. -

-
-
-
- -
-
{{ _("Load the database") }}
- -
Python 3.7.3 (default, Apr  3 2019, 05:39:12)
-[GCC 8.3.0] on linux
-Type "help", "copyright", "credits" or "license" for more information.
->>> import location
->>> d = location.Database("/usr/share/location/database.db")
-
- -
-
{{ _("Search for an Autonomous System by Name") }}
- -
>>> for i in d.search_as("Lightning Wire Labs"):
-...   print(i)
-...
-AS204867 (Lightning Wire Labs GmbH)
-
- -
-
{{ _("Lookup an IP Address") }}
- -
>>> n = d.lookup("81.3.27.38")
->>> n
-<location.Network 81.3.27.0/24>
->>> n.asn
-24679
->>> n.country_code
-'DE'
+
diff --git a/src/templates/location/how-to-use/python.html b/src/templates/location/how-to-use/python.html new file mode 100644 index 00000000..33e67a16 --- /dev/null +++ b/src/templates/location/how-to-use/python.html @@ -0,0 +1,94 @@ +{% extends "../../base.html" %} + +{% block title %}{{ _("How To Use?") }} - {{ _("Python") }}{% end block %} + +{% block container %} +
+ +
+ +
+
+
+
+
+

+ libloc comes with native Python bindings which + are used by its main command-line tool + + location + . + They are the most advanced bindings as they support reading + from the database as well as writing to it. +

+
+
+ +
+
+ {{ _( +
+
+
+ +
+
{{ _("Load the database") }}
+ +
Python 3.7.3 (default, Apr  3 2019, 05:39:12)
+[GCC 8.3.0] on linux
+Type "help", "copyright", "credits" or "license" for more information.
+>>> import location
+>>> d = location.Database("/usr/share/location/database.db")
+
+ +
+
{{ _("Search for an Autonomous System by Name") }}
+ +
>>> for i in d.search_as("Lightning Wire Labs"):
+...   print(i)
+...
+AS204867 (Lightning Wire Labs GmbH)
+
+ +
+
{{ _("Lookup an IP Address") }}
+ +
>>> n = d.lookup("81.3.27.38")
+>>> n
+<location.Network 81.3.27.0/24>
+>>> n.asn
+24679
+>>> n.country_code
+'DE'
+
+
+
+{% end block %} diff --git a/src/web/__init__.py b/src/web/__init__.py index c5028c90..48a13605 100644 --- a/src/web/__init__.py +++ b/src/web/__init__.py @@ -198,6 +198,8 @@ class Application(tornado.web.Application): (r"/location/?", location.IndexHandler), (r"/location/download", tornado.web.RedirectHandler, { "url" : "/location/install" }), (r"/location/how\-to\-use", StaticHandler, { "template" : "location/how-to-use/index.html" }), + (r"/location/how\-to\-use/cli", StaticHandler, { "template" : "location/how-to-use/cli.html" }), + (r"/location/how\-to\-use/python", StaticHandler, { "template" : "location/how-to-use/python.html" }), (r"/location/install", StaticHandler, { "template" : "location/install.html" }), (r"/location/lookup/(.+)", location.LookupHandler),