]> git.ipfire.org Git - ipfire.org.git/commitdiff
location: Split the "How To Use?" page into several pages
authorMichael Tremer <michael.tremer@ipfire.org>
Sun, 31 Mar 2024 19:51:53 +0000 (19:51 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Sun, 31 Mar 2024 19:51:53 +0000 (19:51 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
Makefile.am
src/templates/location/how-to-use/cli.html [new file with mode: 0644]
src/templates/location/how-to-use/index.html
src/templates/location/how-to-use/python.html [new file with mode: 0644]
src/web/__init__.py

index cde0a0b273f752da45a035d109d86e5f81e06fc3..fa2cfc2ac4410753f320e22ec9138ce144381eb5 100644 (file)
@@ -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 (file)
index 0000000..03568c9
--- /dev/null
@@ -0,0 +1,86 @@
+{% extends "../../base.html" %}
+
+{% block title %}{{ _("How To Use?") }} - {{ _("Command Line") }}{% end block %}
+
+{% block container %}
+       <section class="hero is-light">
+               <div class="hero-body">
+                       <div class="container">
+                               <nav class="breadcrumb" aria-label="breadcrumbs">
+                                       <ul>
+                                               <li>
+                                                       <a href="/">
+                                                               {{ _("Home") }}
+                                                       </a>
+                                               </li>
+                                               <li>
+                                                       <a href="/location">
+                                                               {{ _("Location") }}
+                                                       </a>
+                                               </li>
+                                               <li>
+                                                       <a href="/location/how-to-use">
+                                                               {{ _("How To Use?") }}
+                                                       </a>
+                                               </li>
+                                               <li class="is-active">
+                                                       <a href="#" aria-current="page">{{ _("Command Line") }}</a>
+                                               </li>
+                                       </ul>
+                               </nav>
+
+                               <h1 class="title">{{ _("Command Line") }}</h1>
+                       </div>
+               </div>
+       </section>
+
+       <section class="section">
+               <div class="container">
+                       <div class="columns">
+                               <div class="column">
+                                       <div class="content">
+                                               <p>
+                                                       <code>libloc</code> comes with a command line tool which
+                                                       makes it easy to test the library or integrate it into
+                                                       your shell scripts.
+                                                       <code>location(8)</code> 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.
+                                               </p>
+
+                                               <p>
+                                                       Although this is not the fastest way to lookup a large number
+                                                       of IP addresses, <code>location(8)</code> is versatile
+                                                       and very easy to use.
+                                               </p>
+
+                                               <a class="button is-light" href="https://man-pages.ipfire.org/libloc/location.html">
+                                                       {{ _("Man Page") }}
+                                               </a>
+                                       </div>
+                               </div>
+
+                               <div class="column is-narrow">
+                                       <figure class="image is-256x256">
+                                               <img src="{{ static_url("img/bash-logo.svg") }}" alt="{{ _("CLI") }}">
+                                       </figure>
+                               </div>
+                       </div>
+
+                       <div class="block">
+                               <h6 class="title is-6">{{ _("Search for an Autonomous System by Name") }}</h6>
+
+                               <pre><code>$ location search-as "Lightning Wire Labs"
+AS204867 (Lightning Wire Labs GmbH)</code></pre>
+                       </div>
+
+                       <div class="block">
+                               <h6 class="title is-6">{{ _("Lookup an IP Address") }}</h6>
+
+                               <pre><code>$ 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)</code></pre>
+                       </div>
+               </div>
+       </section>
+{% end block %}
index e500233204d49c46a7a99777856564799a4aea96..97e1eed1f9c386ab2fcf141948dd0293b8c5991e 100644 (file)
@@ -3,7 +3,7 @@
 {% block title %}{{ _("How To Use?") }}{% end block %}
 
 {% block container %}
-       <section class="hero is-primary">
+       <section class="hero is-light">
                <div class="hero-body">
                        <div class="container">
                                <nav class="breadcrumb" aria-label="breadcrumbs">
                                                        </a>
                                                </li>
                                                <li class="is-active">
-                                                       <a href="#" aria-current="page">{{ _("How to use?") }}</a>
+                                                       <a href="#" aria-current="page">{{ _("How To Use?") }}</a>
                                                </li>
                                        </ul>
                                </nav>
 
-                               <h1 class="title">{{ _("IPFire Location") }}</h1>
-                               <h6 class="subtitle">
-                                       <code>libloc</code> is versatile, fast and easy to use
-                                       in any application.
-                               </h6>
+                               <h1 class="title">{{ _("How To Use?") }}</h1>
                        </div>
                </div>
        </section>
 
        <section class="section">
                <div class="container">
-                       <div class="columns">
-                               <div class="column">
-                                       <h2 class="title is-2">{{ _("Command Line") }}</h2>
+                       <p>
+                               The heart of the IPFire Location project is a small, lightweight library
+                               called <code>libloc</code>.
 
-                                       <div class="content">
-                                               <p>
-                                                       <code>libloc</code> comes with a command line tool which
-                                                       makes it easy to test the library or integrate it into
-                                                       your shell scripts.
-                                                       <code>location(8)</code> 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.
-                                               </p>
-
-                                               <p>
-                                                       Although this is not the fastest way to lookup a large number
-                                                       of IP addresses, <code>location(8)</code> is versatile
-                                                       and very easy to use.
-                                               </p>
-
-                                               <a class="button is-light" href="https://man-pages.ipfire.org/libloc/location.html">
-                                                       {{ _("Man Page") }}
-                                               </a>
-                                       </div>
-                               </div>
-
-                               <div class="column is-narrow">
-                                       <figure class="image is-256x256">
-                                               <img src="{{ static_url("img/bash-logo.svg") }}" alt="{{ _("CLI") }}">
-                                       </figure>
-                               </div>
-                       </div>
-
-                       <div class="block">
-                               <h6 class="title is-6">{{ _("Search for an Autonomous System by Name") }}</h6>
-
-                               <pre><code>$ location search-as "Lightning Wire Labs"
-AS204867 (Lightning Wire Labs GmbH)</code></pre>
-                       </div>
-
-                       <div class="block">
-                               <h6 class="title is-6">{{ _("Lookup an IP Address") }}</h6>
-
-                               <pre><code>$ 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)</code></pre>
-                       </div>
+                               It sources the data, builds and reads the database.
+                       </p>
                </div>
        </section>
 
        <section class="section">
                <div class="container">
-                       <div class="columns">
-                               <div class="column is-narrow">
-                                       <figure class="image is-256x256">
-                                               <img src="{{ static_url("img/python-logo.svg") }}"
-                                                       alt="{{ _("Python") }}">
-                                       </figure>
-                               </div>
-
-                               <div class="column">
-                                       <h2 class="title is-2">{{ _("Python") }}</h2>
-
-                                       <div class="content">
-                                               <p>
-                                                       <code>libloc</code> comes with native Python bindings which
-                                                       are used by its main command-line tool
-                                                       <a class="text-white" href="https://man-pages.ipfire.org/libloc/location.html">
-                                                               <code>location</code>
-                                                       </a>.
-                                                       They are the most advanced bindings as they support reading
-                                                       from the database as well as writing to it.
-                                               </p>
-                                       </div>
-                               </div>
-                       </div>
-
-                       <div class="block">
-                               <h6 class="title is-6">{{ _("Load the database") }}</h6>
-
-                               <pre><code>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.
-&gt;&gt;&gt; import location
-&gt;&gt;&gt; d = location.Database("/usr/share/location/database.db")</code></pre>
-                       </div>
-
-                       <div class="block">
-                               <h6 class="title is-6">{{ _("Search for an Autonomous System by Name") }}</h6>
-
-                               <pre><code>&gt;&gt;&gt; for i in d.search_as("Lightning Wire Labs"):
-... &nbsp;&nbsp;print(i)
-...
-AS204867 (Lightning Wire Labs GmbH)</code></pre>
-                       </div>
-
-                       <div class="block">
-                               <h6 class="title is-6">{{ _("Lookup an IP Address") }}</h6>
-
-                               <pre><code>&gt;&gt;&gt; n = d.lookup("81.3.27.38")
-&gt;&gt;&gt; n
-&lt;location.Network 81.3.27.0/24&gt;
-&gt;&gt;&gt; n.asn
-24679
-&gt;&gt;&gt; n.country_code
-'DE'</code></pre>
+                       <div class="buttons are-medium">
+                               <a class="button is-light is-fullwidth" href="/location/how-to-use/cli">
+                                       <span class="icon">
+                                               <i class="fa-solid fa-terminal"></i>
+                                       </span>
+                                       <span>{{ _("Command Line") }}</span>
+                               </a>
+
+                               <a class="button is-light is-fullwidth" href="/location/how-to-use/c" disabled>
+                                       {{ _("C/C++") }}
+                               </a>
+
+                               <a class="button is-light is-fullwidth" href="/location/how-to-use/python">
+                                       <span class="icon">
+                                               <i class="fa-brands fa-python"></i>
+                                       </span>
+                                       <span>{{ _("Python") }}</span>
+                               </a>
+
+                               <a class="button is-light is-fullwidth" href="/location/how-to-use/lua" disabled>
+                                       {{ _("Lua") }}
+                               </a>
+
+                               <a class="button is-light is-fullwidth" href="/location/how-to-use/dns" disabled>
+                                       {{ _("DNS") }}
+                               </a>
                        </div>
                </div>
        </section>
diff --git a/src/templates/location/how-to-use/python.html b/src/templates/location/how-to-use/python.html
new file mode 100644 (file)
index 0000000..33e67a1
--- /dev/null
@@ -0,0 +1,94 @@
+{% extends "../../base.html" %}
+
+{% block title %}{{ _("How To Use?") }} - {{ _("Python") }}{% end block %}
+
+{% block container %}
+       <section class="hero is-light">
+               <div class="hero-body">
+                       <div class="container">
+                               <nav class="breadcrumb" aria-label="breadcrumbs">
+                                       <ul>
+                                               <li>
+                                                       <a href="/">
+                                                               {{ _("Home") }}
+                                                       </a>
+                                               </li>
+                                               <li>
+                                                       <a href="/location">
+                                                               {{ _("Location") }}
+                                                       </a>
+                                               </li>
+                                               <li>
+                                                       <a href="/location/how-to-use">
+                                                               {{ _("How To Use?") }}
+                                                       </a>
+                                               </li>
+                                               <li class="is-active">
+                                                       <a href="#" aria-current="page">{{ _("Python") }}</a>
+                                               </li>
+                                       </ul>
+                               </nav>
+
+                               <h1 class="title">{{ _("Python") }}</h1>
+                       </div>
+               </div>
+       </section>
+
+       <section class="section">
+               <div class="container">
+                       <div class="columns">
+                               <div class="column">
+                                       <div class="content">
+                                               <p>
+                                                       <code>libloc</code> comes with native Python bindings which
+                                                       are used by its main command-line tool
+                                                       <a class="text-white" href="https://man-pages.ipfire.org/libloc/location.html">
+                                                               <code>location</code>
+                                                       </a>.
+                                                       They are the most advanced bindings as they support reading
+                                                       from the database as well as writing to it.
+                                               </p>
+                                       </div>
+                               </div>
+
+                               <div class="column is-narrow">
+                                       <figure class="image is-128x128">
+                                               <img src="{{ static_url("img/python-logo.svg") }}"
+                                                       alt="{{ _("Python") }}">
+                                       </figure>
+                               </div>
+                       </div>
+
+                       <div class="block">
+                               <h6 class="title is-6">{{ _("Load the database") }}</h6>
+
+                               <pre><code>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.
+&gt;&gt;&gt; import location
+&gt;&gt;&gt; d = location.Database("/usr/share/location/database.db")</code></pre>
+                       </div>
+
+                       <div class="block">
+                               <h6 class="title is-6">{{ _("Search for an Autonomous System by Name") }}</h6>
+
+                               <pre><code>&gt;&gt;&gt; for i in d.search_as("Lightning Wire Labs"):
+... &nbsp;&nbsp;print(i)
+...
+AS204867 (Lightning Wire Labs GmbH)</code></pre>
+                       </div>
+
+                       <div class="block">
+                               <h6 class="title is-6">{{ _("Lookup an IP Address") }}</h6>
+
+                               <pre><code>&gt;&gt;&gt; n = d.lookup("81.3.27.38")
+&gt;&gt;&gt; n
+&lt;location.Network 81.3.27.0/24&gt;
+&gt;&gt;&gt; n.asn
+24679
+&gt;&gt;&gt; n.country_code
+'DE'</code></pre>
+                       </div>
+               </div>
+       </section>
+{% end block %}
index c5028c90d339f4d163645cbd6871274db7a06fa6..48a136052d12b8f9b6133e3fbaef8583476f79a5 100644 (file)
@@ -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),