### Serve Documentation Locally with MkDocs Source: https://github.com/dorogoy/l1nkzip/blob/master/user-guide/requirements.txt This command serves the MkDocs documentation site locally, allowing you to preview changes before deployment. It starts a local web server that automatically reloads when you make changes to your documentation files. ```shell mkdocs serve ``` -------------------------------- ### Extend Docker Image for MySQL Support Source: https://github.com/dorogoy/l1nkzip/blob/master/user-guide/docs/selfhosting.md This Dockerfile example demonstrates how to extend the official L1nkZip Docker image to include support for MySQL by installing the necessary Python driver. ```Dockerfile FROM dorogoy/l1nkzip:latest RUN pip install --no-cache-dir MySQL-python ``` -------------------------------- ### Create URL with Python Source: https://github.com/dorogoy/l1nkzip/blob/master/user-guide/docs/index.md An example of how to shorten a URL using Python's `httpx` library. It sends a POST request to the L1nkZip API with the URL in the request body. ```Python import httpx url = "https://www.google.com" header = {"Content-Type": "application/json"} response = httpx.post("https://l1nk.zip/url", header=header, json={"url": url}) print(response.json()) ``` -------------------------------- ### Create URL with Curl Source: https://github.com/dorogoy/l1nkzip/blob/master/user-guide/docs/index.md Example of creating a shortened URL using the `curl` command-line tool. It sends a POST request with a JSON payload containing the URL to be shortened. ```Bash curl -X 'POST' \ 'https://l1nk.zip/url' \ -H 'Content-Type: application/json' \ -d '{"url": "https://www.google.com"}' ``` -------------------------------- ### Run Local Server for L1nkZip Site Source: https://github.com/dorogoy/l1nkzip/blob/master/user-guide/README.md Runs a local development server to preview the L1nkZip site. This allows for live reloading as changes are made. ```bash make run ``` -------------------------------- ### Build Documentation with MkDocs Source: https://github.com/dorogoy/l1nkzip/blob/master/user-guide/requirements.txt This command builds the documentation site using MkDocs. MkDocs is a fast, simple, and downright gorgeous static site generator that's perfect for building project documentation. It requires a Markdown file as input and generates a static HTML site. ```shell mkdocs build ``` -------------------------------- ### Deploy Documentation to GitHub Pages Source: https://github.com/dorogoy/l1nkzip/blob/master/user-guide/requirements.txt This command imports the built documentation (typically from the 'site' directory) into the 'gh-pages' branch of your GitHub repository, which is commonly used for hosting GitHub Pages. Ensure you have built the documentation first using 'mkdocs build'. ```shell ghp-import -n -p site ``` -------------------------------- ### Build L1nkZip Site Source: https://github.com/dorogoy/l1nkzip/blob/master/user-guide/README.md Builds the L1nkZip site. This command is used to generate the static site files. ```bash make build ``` -------------------------------- ### Create URL with Httpx Source: https://github.com/dorogoy/l1nkzip/blob/master/user-guide/docs/index.md Demonstrates creating a shortened URL using the `httpx` command-line tool. This is a more concise way to send a POST request with JSON data. ```Bash httpx -m POST -j '{"url": "https://www.google.com"}' https://l1nk.zip/url ``` -------------------------------- ### Kubernetes StatefulSet for L1nkZip with Litestream Source: https://github.com/dorogoy/l1nkzip/blob/master/user-guide/docs/selfhosting.md This YAML defines a Kubernetes StatefulSet to deploy L1nkZip. It includes an init container for Litestream to restore the database, a container for Litestream replication, and the L1nkZip application container. It configures environment variables for secrets and config maps, and sets up persistent storage. ```yaml --- apiVersion: v1 kind: ConfigMap metadata: name: litestream data: litestream.yml: | dbs: - path: /data/l1nkzip.db replicas: - type: s3 bucket: path: l1nkzip.db endpoint: region: force-path-style: true --- apiVersion: v1 kind: Service metadata: name: l1nkzip spec: selector: app: l1nkzip type: ClusterIP ports: - name: http protocol: TCP port: 80 targetPort: 80 --- apiVersion: apps/v1 kind: StatefulSet metadata: name: l1nkzip spec: selector: matchLabels: app: l1nkzip serviceName: l1nkzip replicas: 1 template: metadata: labels: app: l1nkzip spec: initContainers: - name: init-litestream image: litestream/litestream:0.3.9 args: [ "restore", "-if-db-not-exists", "-if-replica-exists", "-v", "$(DB_NAME)", ] volumeMounts: - name: l1nkzip mountPath: /data - name: litestream mountPath: /etc/litestream.yml subPath: litestream.yml env: - name: LITESTREAM_ACCESS_KEY_ID valueFrom: secretKeyRef: name: l1nkzip-secret key: LITESTREAM_ACCESS_KEY_ID - name: LITESTREAM_SECRET_ACCESS_KEY valueFrom: secretKeyRef: name: l1nkzip-secret key: LITESTREAM_SECRET_ACCESS_KEY - name: DB_NAME valueFrom: configMapKeyRef: name: l1nkzip-config key: DB_NAME containers: - name: litestream image: litestream/litestream:0.3.9 args: ["replicate"] volumeMounts: - name: l1nkzip mountPath: /data - name: litestream mountPath: /etc/litestream.yml subPath: litestream.yml env: - name: LITESTREAM_ACCESS_KEY_ID valueFrom: secretKeyRef: name: l1nkzip-secret key: LITESTREAM_ACCESS_KEY_ID - name: LITESTREAM_SECRET_ACCESS_KEY valueFrom: secretKeyRef: name: l1nkzip-secret key: LITESTREAM_SECRET_ACCESS_KEY ports: - name: metrics containerPort: 9090 - name: l1nkzip image: dorogoy/l1nkzip:latest imagePullPolicy: Always ports: - name: http containerPort: 80 volumeMounts: - name: l1nkzip mountPath: /data - name: litestream mountPath: /etc/litestream.yml subPath: litestream.yml env: - name: TOKEN valueFrom: secretKeyRef: name: l1nkzip-secret key: TOKEN - name: GENERATOR_STRING valueFrom: secretKeyRef: name: l1nkzip-secret key: GENERATOR_STRING - name: PHISHTANK value: "anonymous" - name: DB_TYPE value: sqlite - name: DB_NAME valueFrom: configMapKeyRef: name: l1nkzip-config key: DB_NAME - name: API_DOMAIN valueFrom: configMapKeyRef: name: l1nkzip-config key: API_DOMAIN - name: SITE_URL valueFrom: configMapKeyRef: name: l1nkzip-config key: SITE_URL volumes: - name: litestream configMap: name: litestream - name: l1nkzip persistentVolumeClaim: claimName: l1nkzip volumeClaimTemplates: - metadata: name: l1nkzip spec: accessModes: - ReadWriteOnce resources: requests: storage: 1Gi ``` -------------------------------- ### L1nkZip API Documentation Source: https://github.com/dorogoy/l1nkzip/blob/master/README.md Provides details on the available API endpoints for the L1nkZip URL shortener. ```APIDOC L1nkZip API: Base URL: https://l1nk.zip Endpoints: GET /docs Description: Displays the interactive API documentation (Swagger UI). Returns: HTML page with API documentation. POST / Description: Creates a new short URL. Request Body: content-type: application/json schema: type: object properties: url: { type: string, description: "The original long URL to shorten." } required: - url Responses: 200 OK: description: Successfully created short URL. content: application/json: schema: type: object properties: short_url: { type: string, description: "The generated short URL." } original_url: { type: string, description: "The original long URL." } 400 Bad Request: description: Invalid input, e.g., missing URL. 500 Internal Server Error: description: Server error during URL shortening. GET /{short_url} Description: Redirects to the original URL associated with the short URL. Parameters: short_url: { type: string, description: "The short identifier for the URL." } Responses: 307 Temporary Redirect: description: Redirects to the original URL. headers: Location: { type: string, description: "The original long URL." } 404 Not Found: description: The provided short URL does not exist. GET /admin/urls Description: Retrieves a list of all shortened URLs and their original URLs. Returns: 200 OK: description: List of all shortened URLs. content: application/json: schema: type: array items: type: object properties: short_url: { type: string } original_url: { type: string } created_at: { type: string, format: date-time } 500 Internal Server Error: description: Server error retrieving URL list. ``` -------------------------------- ### Pull L1nkZip Docker Image Source: https://github.com/dorogoy/l1nkzip/blob/master/user-guide/docs/selfhosting.md Command to pull the latest official L1nkZip Docker image from Docker Hub. ```bash docker pull dorogoy/l1nkzip ``` -------------------------------- ### Create URL with PHP Source: https://github.com/dorogoy/l1nkzip/blob/master/user-guide/docs/index.md This snippet shows how to shorten a URL using PHP with the `curl` extension. It makes a POST request to the L1nkZip API, setting the necessary headers and sending the URL as JSON. ```PHP "https://www.google.com"])); curl_setopt($ch, CURLOPT_HTTPHEADER, ["Content-Type: application/json"]); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $response = curl_exec($ch); curl_close($ch); echo $response; ?> ``` -------------------------------- ### L1nkZip API Endpoints Source: https://github.com/dorogoy/l1nkzip/blob/master/user-guide/docs/index.md This section outlines the available API endpoints for the L1nkZip URL shortener. It details the HTTP methods, request formats, and expected responses for interacting with the service. ```APIDOC OpenAPI Specification for L1nkZip: Paths: /url: post: summary: Create a shortened URL operationId: create_url_url_post requestBody: required: true content: application/json: schema: type: object properties: url: type: string format: url description: The original URL to shorten. responses: '200': description: Successful creation of a shortened URL. content: application/json: schema: type: object properties: short_url: type: string description: The shortened URL. original_url: type: string description: The original URL provided. '422': description: Unprocessable Entity - Invalid input data. Components: schemas: URLShortenRequest: type: object properties: url: type: string format: url description: The original URL to shorten. required: - url URLShortenResponse: type: object properties: short_url: type: string description: The shortened URL. original_url: type: string description: The original URL provided. required: - short_url - original_url ``` -------------------------------- ### Clean L1nkZip Site Environment Source: https://github.com/dorogoy/l1nkzip/blob/master/user-guide/README.md Cleans the build environment for the L1nkZip site. This command removes generated files and temporary data. ```bash make clean ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.