Skip to content

Commit

Permalink
[Navigate Results][Added] A header and navigation bar
Browse files Browse the repository at this point in the history
Closes #582
  • Loading branch information
set-soft committed Mar 29, 2024
1 parent 0433088 commit 29c86ce
Show file tree
Hide file tree
Showing 9 changed files with 293 additions and 20 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- 3D/2D renderers: support for ranges in the `show_components` and `highlight`
options. So one entry can be something like *R10-R20*. Can be disabled
using the global option `allow_component_ranges`. (See yaqwsx/PcbDraw#159)
- Navigate results: A header and navigation bar (#582)

### Changed
- CI/CD: we now filter some warnings that are always generated by docker
Expand Down
16 changes: 16 additions & 0 deletions docs/samples/generic_plot.kibot.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1744,12 +1744,28 @@ outputs:
type: 'navigate_results'
dir: 'Example/navigate_results_dir'
options:
# [boolean=true] Add a header containing information for the project
header: true
# [string=''] The name of a file to create at the main output directory linking to the home page
link_from_root: ''
# [string|boolean=''] PNG file to use as logo, use false to remove.
# The KiBot logo is used by default
logo: ''
# [string='https://github.com/INTI-CMNB/KiBot/'] Target link when clicking the logo
logo_url: 'https://github.com/INTI-CMNB/KiBot/'
# [boolean=true] Add a side navigation bar to quickly access to the outputs
nav_bar: true
# [string='%f-%i%I%v.%x'] Filename for the output (%i=html, %x=navigate). Affected by global options
output: '%f-%i%I%v.%x'
# [boolean=false] Skip outputs with `run_by_default: false`
skip_not_run: false
# [string=''] Title for the page, when empy KiBot will try using the schematic or PCB title.
# If they are empty the name of the project, schematic or PCB file is used.
# You can use %X values and KiCad variables here
title: ''
# [string|boolean=''] Target link when clicking the title, use false to remove.
# KiBot will try with the origin of the current git repo when empty
title_url: ''
# Netlist:
# The netlist can be generated in the classic format and in IPC-D-356 format,
# useful for board testing
Expand Down
1 change: 1 addition & 0 deletions docs/source/Changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ Added
``highlight`` options. So one entry can be something like *R10-R20*.
Can be disabled using the global option ``allow_component_ranges``.
(See yaqwsx/PcbDraw#159)
- Navigate results: A header and navigation bar (#582)

Changed
~~~~~~~
Expand Down
12 changes: 12 additions & 0 deletions docs/source/configuration/outputs/navigate_results.rst
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,19 @@ Parameters:

- **link_from_root** :index:`: <pair: output - navigate_results - options; link_from_root>` [string=''] The name of a file to create at the main output directory linking to the home page.
- **output** :index:`: <pair: output - navigate_results - options; output>` [string='%f-%i%I%v.%x'] Filename for the output (%i=html, %x=navigate). Affected by global options.
- ``header`` :index:`: <pair: output - navigate_results - options; header>` [boolean=true] Add a header containing information for the project.
- ``logo`` :index:`: <pair: output - navigate_results - options; logo>` [string|boolean=''] PNG file to use as logo, use false to remove.
The KiBot logo is used by default.

- ``logo_url`` :index:`: <pair: output - navigate_results - options; logo_url>` [string='https://github.com/INTI-CMNB/KiBot/'] Target link when clicking the logo.
- ``nav_bar`` :index:`: <pair: output - navigate_results - options; nav_bar>` [boolean=true] Add a side navigation bar to quickly access to the outputs.
- ``skip_not_run`` :index:`: <pair: output - navigate_results - options; skip_not_run>` [boolean=false] Skip outputs with `run_by_default: false`.
- ``title`` :index:`: <pair: output - navigate_results - options; title>` [string=''] Title for the page, when empy KiBot will try using the schematic or PCB title.
If they are empty the name of the project, schematic or PCB file is used.
You can use %X values and KiCad variables here.
- ``title_url`` :index:`: <pair: output - navigate_results - options; title_url>` [string|boolean=''] Target link when clicking the title, use false to remove.
KiBot will try with the origin of the current git repo when empty.


- **type** :index:`: <pair: output - navigate_results; type>` 'navigate_results'
- ``category`` :index:`: <pair: output - navigate_results; category>` [string|list(string)=''] The category for this output. If not specified an internally defined category is used.
Expand Down
1 change: 1 addition & 0 deletions docs/source/dependencies.rst
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@
- Compare with files in the repo for `diff`
- Find commit hash and/or date for `kikit_present`
- Compare with files in the repo for `kiri`
- Find origin url for `navigate_results`
- Find commit hash and/or date for `pcb_replace`
- Find commit hash and/or date for `sch_replace`
- Find commit hash and/or date for `set_text_variables`
Expand Down
8 changes: 3 additions & 5 deletions kibot/bom/html_writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
"""
import os
from base64 import b64encode
from struct import unpack
from .columnlist import ColumnList, BoMError
from .kibot_logo import KIBOT_LOGO, KIBOT_LOGO_W, KIBOT_LOGO_H
from ..misc import read_png

BG_GEN = "#DCF5E4"
BG_KICAD = "#F5DCA9"
Expand Down Expand Up @@ -273,11 +273,9 @@ def content_table(html, groups, headings, head_names, cfg, link_datasheet, link_


def embed_image(file):
with open(file, 'rb') as f:
s = f.read()
if not (s[:8] == b'\x89PNG\r\n\x1a\n' and (s[12:16] == b'IHDR')):
s, w, h = read_png(file)
if s is None:
raise BoMError('Only PNG images are supported for the logo')
w, h = unpack('>LL', s[16:24])
return int(w), int(h), 'data:image/png;base64,'+b64encode(s).decode('ascii')


Expand Down
20 changes: 15 additions & 5 deletions kibot/misc.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
# -*- coding: utf-8 -*-
# Copyright (c) 2020-2023 Salvador E. Tropea
# Copyright (c) 2020-2023 Instituto Nacional de Tecnología Industrial
# License: GPL-3.0
# Copyright (c) 2020-2024 Salvador E. Tropea
# Copyright (c) 2020-2024 Instituto Nacional de Tecnología Industrial
# License: AGPL-3.0
# Project: KiBot (formerly KiPlot)
""" Miscellaneous definitions """

import re
import os
from contextlib import contextmanager
import os
import re
from struct import unpack


# Error levels
Expand Down Expand Up @@ -442,3 +443,12 @@ def hide_stderr():

def version_str2tuple(ver):
return tuple(map(int, ver.split('.')))


def read_png(file):
with open(file, 'rb') as f:
s = f.read()
if not (s[:8] == b'\x89PNG\r\n\x1a\n' and (s[12:16] == b'IHDR')):
return None, None, None
w, h = unpack('>LL', s[16:24])
return s, w, h
Loading

0 comments on commit 29c86ce

Please sign in to comment.