Commit graph

26 commits

Author SHA1 Message Date
Jonathan Hodgson
7a032b7cdb 2 bug fixes - git not always working and verbose pandoc
Pandoc would output warnings about a lack of title, although we are not
using it in the template.

Also, the tool would fail to do some git commands because it was
checking the wrong folder
2020-12-31 16:57:47 +00:00
Jonathan Hodgson
6641d61b1f Causes the convert tool to copy other files
Any non-markdown files (except the database) will also be copied to the
directory when doing a convert.
2020-12-31 09:57:25 +00:00
Jonathan Hodgson
69bfb3d395 Merge branch 'convert' 2020-12-31 09:48:51 +00:00
Jonathan Hodgson
7d554d5326 Adds the ability to convert to html
Issue #14

I still want, at some point, to add to other formats but this is fine
for now.

The tool uses pandoc to do the conversion from md to html

A sample template (without any styling) is provided. This can be
overwritten in $HOME/.config/kb/templates/main.html or in the
knowledgebase directory under `templates`.
2020-12-31 09:46:23 +00:00
Jonathan Hodgson
cac4584bdf Fix bug when editing a file title
The file needs to be moved although the tags weren't being updated
properly
2020-12-31 00:07:20 +00:00
Jonathan Hodgson
4c891efdce Start work on export options
I have started an html export. So far a toc is generated
2020-12-31 00:06:24 +00:00
Jonathan Hodgson
a9cdb7dfe9 Fix fuzzy creation of new file
FZF exits with a status of 1 if nothing was selected. This is often the
case though if we are creating a new file so I added `|| true` to make
bash continue anyway
2020-12-30 22:21:58 +00:00
Jonathan Hodgson
73894bb252 Make the update and view file changes use all command line positions
Instead of using $1 for file names, $* is used which results in spaces
being allowed without quoting.

This is in line with how the new command works.

As an example, it means the command

```
kb edit this is a test
```

will try and edit a file with the title "this is a test" rather than
"this"
2020-12-30 19:26:15 +00:00
Jonathan Hodgson
05e5cac976 Fix 2 bugs. Deleting file without yaml file and multi-word delete
The first bug output an error if trying to stage the deletion of the
yaml file if the file never existed. The error is now piped to /dev/null
and `|| true` is appended to the line which causes the script to carry
on execution

The second change is when deleting a file, you no longer have to quote
the file name if it is a multi word file. This puts it in line with the
new command
2020-12-30 19:21:31 +00:00
Jonathan Hodgson
a504c212ef Adds perge-tags option 2020-12-30 17:42:22 +00:00
Jonathan Hodgson
6206986546 Fix handling of yaml files when deleting entries 2020-12-30 17:25:04 +00:00
Jonathan Hodgson
a3bbe9b4a2 Adds the ability to add files that already exist
Work on #16

This was a relatively large amount of work. It introduces assets which
are stored in the assets sub directory and stored in the database with
the asset type in the database.
2020-12-30 16:42:47 +00:00
Jonathan Hodgson
980eef941b Fix yaml retrieval 2020-12-29 09:37:58 +00:00
Jonathan Hodgson
ccbb335ec4 Adds separate functions for yaml header and yaml file 2020-12-29 08:48:25 +00:00
Jonathan Hodgson
51ca57da7f Adds support for yaml files rather than yaml headers 2020-12-29 08:45:14 +00:00
Jonathan Hodgson
d3803d9d33 Merge branch 'master' into add-assets 2020-12-29 08:02:28 +00:00
Jonathan Hodgson
3f02dd3ed5 Remove unnecessary chunk of commented code 2020-12-23 12:09:21 +00:00
Jonathan Hodgson
4731545df5 Adds git-lfs as a dependency and initialises lfs in the repo 2020-12-23 11:43:18 +00:00
Jonathan Hodgson
d56d5ddbfd Fix inconsistency between help message and actions for fzf
ctrl-v should view rather than ctrl-o
2020-12-22 09:38:21 +00:00
Jonathan Hodgson
d70f5398a3 Adds the ability to index folder and re-populate the db
Misc:
The arguments are now sorted alphabetically in the main funciton

close #4
2020-12-22 09:38:04 +00:00
Jonathan Hodgson
5863d5a58f Moves FZF related code into an include 2020-12-22 09:15:35 +00:00
Jonathan Hodgson
0ac730ca3c Adds pager option and uses $PAGER environment variable
Due to bat also reading the $PAGER environment variable, I first look to
see if bat is available. If it is, I use that. If it isn't, I use the
$PAGER environment variable. If that's not available, I use cat.

I also added the --editor flag to the help output which had clearly been
missed

Close #12
2020-12-22 08:58:53 +00:00
Jonathan Hodgson
f8d04a304a Adds key combinations for fuzzy search
Currently:
* ctrl-n - new file from query
* ctrl-o - view file
* ctrl-e - edit file
* ctrl-d - delete file

close #11
2020-12-21 18:28:13 +00:00
Jonathan Hodgson
caab854c09 Adds update command for externally modified files
This can be used when a file is modified externally. It will update the
sqlite database and potentially run git commands for the change.

If there are 2 files provided, it assumes that the file was moved. The
first filename should be the old file.

The new, edit and delete functions were also re factored slightly to use
this new update function.

Relevant to #4
Close #2
Close #1
2020-12-20 20:04:52 +00:00
Jonathan Hodgson
b84cf93f4a Adds list-tags option
This will list the tags along with the number of number of times it is
used.

An optional --noheader flag can be passed after the command to prevent
the header being printed.

e.g.

```
$ kb list-tags
name              count
----------------  -----
Linux             2
Authentication    1
Pentesting        1
Enumeration       3
Network Protocol  2
```

```
$ kb list-tags --noheader
Linux             2
Authentication    1
Pentesting        1
Enumeration       3
Network Protocol  2
```

This --noheader flag was also added to the list command

Close #10
2020-12-20 18:25:25 +00:00
Jonathan Hodgson
ac031344d3 Splits up file into smaller files
Closes issue #9
2020-12-20 17:07:17 +00:00