Commit Graph

362 Commits

Author SHA1 Message Date
Matthias Beyer ed8546c7dd Reimplement link module with header Partial
This patch reimplements the "link" module using the
`toml_query::read::Partial` feature.

Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-06-23 21:06:45 +02:00
Matthias Beyer cdc90f7be7 Refactor: Remove notion of "external link"s
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-06-23 13:11:49 +02:00
Matthias Beyer 59ddb70345 Fix: Make sure links are sorted and deduplicated 2019-06-23 11:06:19 +02:00
Matthias Beyer d89a700fd1 Remove annotateable linking
This patch removes the annotateable linking feature from libimagentrylink.
It was not used anyways.

Also, this patch rewrites the complete linking code to use the
toml-query "typed" feature rather than constructing everything by
itself.

This removes a lot of unmaintainable boilerplate code.

Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-06-23 10:35:14 +02:00
Matthias Beyer 1ffdb72315 Remove obsolete (internal) function 2019-06-22 12:00:02 +02:00
Matthias Beyer 5dc6829354 Rename module: linker -> linkable
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-06-21 23:22:48 +02:00
Matthias Beyer ef17930c29 Rename interface
With this patch, the libimagentrylink library interface gets renamed.

The trait gets renamed to the more descriptive name "Linkable", the
functions get renamed to not contain any notion of "internal" anymore.

This patch also adapts the whole source tree for the new libimagentrylink
interface, also renaming variables to not contain "_internal_" anymore.

Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-06-21 23:22:47 +02:00
Matthias Beyer f21b6e53a2 Merge branch 'libimagentrylink-split' into master 2019-06-15 16:48:50 +02:00
Matthias Beyer 901502b67e Split "internal" module into several submodules
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-05-31 12:48:00 +02:00
Matthias Beyer d02d53594e Fix debug output message 2019-05-31 12:48:00 +02:00
Matthias Beyer d2a5e8fb59 Rename functions: *_external_link -> *_url
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-05-31 12:48:00 +02:00
Matthias Beyer 7f2e4c8442 Adapt tested path 2019-05-31 12:48:00 +02:00
Matthias Beyer 8b66672772 Fix libimagentrymarkdown for new url lib 2019-05-31 12:48:00 +02:00
Matthias Beyer c33c29e8e2 Fix import for new libimagentryurl lib
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-05-31 12:48:00 +02:00
Matthias Beyer 098d25db89 Move code from external libimagentrylink module to libimagentryurl
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-05-31 12:48:00 +02:00
Matthias Beyer 5cb641044f Add libimagentryurl
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-05-30 17:51:33 +02:00
Matthias Beyer 11955f699f Change interface of Viewer to propagate io errors
Because we need to catch errors that are caused by a borken pipe when
writing to stdout (for example), this patch changes the interface of the
Viewer trait to return an error enum that can be used to check whether
an IO error happened.

The calling code can then decide whether to ignore a broken pipe error
or whether to handle it properly.

Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-05-30 11:12:43 +02:00
Matthias Beyer 151e4d0aa8 Replace deprecated functioncall
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-05-30 10:09:43 +02:00
Matthias Beyer a7d53e47d1 Update toml-query to 0.9.0
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-05-29 18:39:25 +02:00
Matthias Beyer 1482f70320 Update dependency: toml: 0.4 -> 0.5
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-05-29 18:39:25 +02:00
Matthias Beyer 5ff2c3e8e3 Remove lazy_static
we don't need lazy static here, so remove it and the dependency as well.

Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-05-25 10:43:24 +02:00
Matthias Beyer 5c8af4460e Fix: Entries::in_collection() should be able to return error
This patch changes the Entries::in_collection() interface to return a
Result<()>. This is needed because the fs backend implementation should
be able to check whether a directory actually exists whenever we change
the iterator.

If the implementation detects that the directory does not exist, we can
fail early and error out.

All usages of the interface are adapted by the patch as well.

Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-05-18 13:37:46 +02:00
Matthias Beyer 5a250bd991 Remove InternalLinker::set_internal_links()
This function needs to be removed because of the following problem:

When linking from one entry to another, and then removing the link in
the first entry with ::set_internal_links(vec![]), we end up with a
dangling link in the second entry, because the ::set_internal_links()
function does not take care of removing the links in the "other"
entries.

Actually, it is not even able to do so, because it would need to
`Store::get()` those entries, but it does not have access to the store.

Adding a `store` parameter to the function would be possible, but only
increase its complexity unnecessarily. This is why I opt for removing
this function (which is btw not used once in the whole imag codebase).

Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-05-18 02:31:03 +02:00
Matthias Beyer 27b75ba2fc Add more context in error messages
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-05-18 00:55:10 +02:00
Matthias Beyer 5ebbcb774a Add more context in error messages
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-05-18 00:55:10 +02:00
Matthias Beyer b808658648 Add more context in error messages
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-05-18 00:55:10 +02:00
Matthias Beyer f540a317b0 Add more context in error messages
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-05-18 00:55:10 +02:00
Matthias Beyer c02b2f88de Add more context in error messages
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-05-18 00:55:10 +02:00
Matthias Beyer c7ea58eda2 Add more context in error messages
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-05-18 00:55:10 +02:00
Matthias Beyer d8bcb8ca8e Add more context in error messages
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-05-18 00:55:10 +02:00
Matthias Beyer f44e10e295 Add more context in error messages
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-05-18 00:55:10 +02:00
Matthias Beyer 322c063450 Add more context in error messages
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-05-18 00:55:10 +02:00
Matthias Beyer 6e0a179550 Add more context in error messages
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-05-18 00:55:10 +02:00
Matthias Beyer 1d89844613 Run 'cargo fix' for rust-2018
With this patch we move the codebase to Rust-2018.

The diff was generated by executing

    cargo fix --all --all-features --edition

on the codebase.

Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-05-18 00:20:59 +02:00
Matthias Beyer 427eac76fe Add Ref::get_path_with_basepath_setting()
This function can be used to override the basepath setting from the
header of the entry so that another basepath is used for looking
up/constructing the actual filepath.

This might come in handy at some point.

Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-04-22 14:40:07 +02:00
Matthias Beyer cf234437d7 Implement Partial for Config
With this implemented, we can fetch the appropriate configuration easily
from the configuration.

Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-04-22 13:06:26 +02:00
Matthias Beyer 2854e88dcc Rename: "ref.collection" to "ref.basepath"
The setting in the header should reflect the name of the setting in the
configuration file, for a better user experience.

Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-04-22 13:06:26 +02:00
Matthias Beyer 7ae2d926cc Use toml-query master branch during development
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-04-22 13:06:26 +02:00
Matthias Beyer 31e3116b48 Revert "Remove GetIter"
This reverts commit a49522dc86770a741d61d548351ad69dfc56d1fa.
2019-04-14 00:16:47 +02:00
Matthias Beyer aa3fdb88d5 Remove GetIter
Because the code is not used.

Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-04-14 00:16:47 +02:00
Matthias Beyer 4afebbe9e4 Remove FilterLinksIter
Because the code is not used.

Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-04-14 00:16:47 +02:00
Matthias Beyer 1f515b1d0d Remove DeleteUnlinkedIter
Because the code is not used.

Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-04-14 00:16:47 +02:00
Matthias Beyer cb4d5367e4 Rewrite all usages of ModuleEntryPath
Because the code was so complex before, we had to create an object and
then cast that object into a `StoreId` rather than just creating a
`StoreId` object right away.

With this patch, we're using the code-generation approach to generate a
function that creates a `StoreId` object based on the name of the
current module. That's way easier and error handling was also improved
by the switch to the new implementation.

The patch also includes a rewrite of all usages of ModuleEntryPath and
changes them to `module_path::new_id()` calls.

Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-04-13 22:39:39 +02:00
Matthias Beyer de522ec0f2 Fix for rust beta compiler
The beta compiler reports duplicated input:

error: the item `IntoValues` is imported redundantly
   --> lib/entry/libimagentrylink/src/internal.rs:398:13
    |
36  | use self::iter::IntoValues;
    |     ---------------------- the item `IntoValues` is already imported here
...
398 |         use internal::iter::IntoValues;
    |             ^^^^^^^^^^^^^^^^^^^^^^^^^^
    |

so we fix this here.

Other imports were fixed as well.

Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-04-13 22:06:53 +02:00
Matthias Beyer 19622f41ae Do not ignore errors when collecting links
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-03-09 13:30:12 +01:00
Matthias Beyer 581da9c9cf Remove old comment
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-03-09 13:30:12 +01:00
Matthias Beyer 9af10fd2eb Fix indention
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-03-09 12:24:40 +01:00
Matthias Beyer 734112b856 Simplify
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-03-09 12:24:20 +01:00
Matthias Beyer d19020c3f5 Remove unnecessary Error::from() call
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-03-09 12:24:09 +01:00
Matthias Beyer d32f41aeab Outsource hashing itself so that we can re-use it
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-02-22 11:23:57 +01:00
Matthias Beyer b2fbf1e462 Add debug and trace output
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-02-20 23:14:43 +01:00
Matthias Beyer dfc02a5679 Move helper function to libimagentref::util
This moves the helper function for getting the `Config` object from the
configuration file via the runtime.

Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-02-20 16:22:52 +01:00
Matthias Beyer 0a62548173 Add function to get relative file path
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-02-20 14:43:21 +01:00
Matthias Beyer ed862db76f Fix: Strip the prefix of the path
The previous implementation did not strip the prefix of the "relpath"
header value, which resulted in the whole path being in the header,
which is obviously wrong.

Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-02-20 12:31:37 +01:00
Matthias Beyer 04e006154c Fix: Use "ref.relpath" as path to header value
The header value for the relative path is at "ref.relpath". This fixes
the wrong selector.

Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-02-19 21:51:44 +01:00
Matthias Beyer ac5a3c0298 Reimplement LinkProcessor::process() for new libimagentryref API
The documentation of the function kind of explains why this change is
necessary. It might get changed in the future so that the user has more
flexibility.

Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-02-17 11:09:48 +01:00
Matthias Beyer d8ad741fc2 Rewrite libimagentrymarkdown imports 2019-02-17 11:09:48 +01:00
Matthias Beyer db7121ccba Rewrite library
* Remove old code
* Rewrite with tests

This implements a fassade pattern for ref library

With the fassade, we can specify the hasher in a rather easy way, which
is not possible with default generics for traits.

The "default" part in "default generic type" is not properly implemented
yet (as visible in the tests), as I don't know how to realize this.

For simplicity, the `hasher` module exports a `default` module with a
`DefaultHasher` type, which resolves to the `Sha1Hasher`.

Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-02-17 11:09:48 +01:00
Matthias Beyer 820ac41443 Add trace output
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-02-17 10:47:46 +01:00
Matthias Beyer 84c6a1981e Fix: If the field is not available, return false
The function is for checking whether a flag is set. If the flag is not
available, the flag is obviously not set.

Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-02-17 10:47:46 +01:00
Matthias Beyer 8fb4bcf0c6 Fix for new StoreId::new() interface
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-02-15 20:53:29 +01:00
Matthias Beyer 972cba7c31 Adapt to new libimagstore::iter::Entries API
Use Entries::into_storeid_iter() for transforming iterator into right
type.

Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-02-15 20:53:29 +01:00
Matthias Beyer f64b87b4a8 Adapt to new libimagstore::iter::Entries API
Use Entries::into_storeid_iter() for transforming iterator into right
type.

Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-02-15 20:53:29 +01:00
Matthias Beyer c6cc1804e7 Adapt to new libimagstore::iter::Entries API
Use Entries::into_storeid_iter() for transforming iterator into right
type.

Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-02-15 20:53:29 +01:00
Matthias Beyer 14a2485a8a Change signature: Link::exists(&Store)
This change is necessary because we need the store now to check whether
a StoreId exists.

Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-02-15 20:53:29 +01:00
Matthias Beyer 429ef9bc4c Fix libimagentrylink for new StoreId API
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-02-15 20:53:29 +01:00
Matthias Beyer 642702b724 Rewrite: StoreId::new_baseless() -> StoreId::new()
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-02-15 20:53:28 +01:00
Matthias Beyer b66371f79b Rewrite Store::new* API: libimagstore does not export backend types
With this change applied, libimagstore does not export backend
representing types anymore.

This change is necessar because when we want to switch the `StoreId`
implementation from "complex and stateful" to "Stateless and Cow<'_,
&str>", we need to be able to have a type which represents a "`StoreId`
plus the path of the Store itself".
This "the path of the Store itself" is passed around as reference, to
minimize runtime impact.

Because such a type should not be exported by the libimagstore crate, we
make it `pub(crate)` internally. But because the backend APIs also have
to use this type, we would export the (private) type in the APIs of the
backend.

Because of that we make the backend API also non-visible to crate users,
which also decreases the surface of the libimagstore API itself.

Besides:
Remove function `Link::with_base()` which is not needed anymore (was
used in tests only).

Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-02-15 20:53:28 +01:00
Matthias Beyer 171b42307d Add feature to trim content on the right
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-02-11 03:52:04 +01:00
Matthias Beyer 19912f5e88 Add Is::remove_isflag() for removing header flags
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-02-11 03:22:56 +01:00
Matthias Beyer 03e0864268 Merge branch 'unnamed-annotations' into master-ff
This merge adds several patches to improve libimagannotation and
imag-annotate.
2019-02-10 17:07:35 +01:00
Matthias Beyer d8cd10a384 Remove iterator types
With this patch, libimagentryannotation does not have special iterator
types anymore. This makes the whole thing more comfortable to use.

In imag-annotate, the parameter for the functioncall was removed.

Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-02-10 01:00:33 +01:00
Matthias Beyer ed01f8b463 Make annotations unnamed (automatically UUID named)
It makes no sense to name annotations, a user only cares about whether
there are annotations or not, or their contents. A name has no meaning
in this context.

Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-02-10 00:58:21 +01:00
Matthias Beyer afe275692e Fix: Do not use deprecated StoreId::exists() function
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-02-09 01:03:28 +01:00
Matthias Beyer 9185abcfa5 Update copyright years
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-01-03 18:41:36 +01:00
Matthias Beyer 1ce780795a Do not use StoreId::local() here 2018-11-26 18:19:10 +01:00
Matthias Beyer 496c06d15a Update lazy_static to 1.2
1.2 of lazy_static brings functionality to have no panics in the code,
which is what we try to have.

Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2018-11-11 13:05:55 +01:00
Matthias Beyer 9fca66aa89 Forbid unsafe code in all crates 2018-11-11 13:05:55 +01:00
Matthias Beyer 4e516ee19d Update version strings
...for the next release, which will be imag 0.10.0!

Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2018-11-10 11:56:37 +01:00
Matthias Beyer 17d4123898 Update dependencies from git versions to proper versions.
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2018-11-09 22:14:11 +01:00
Matthias Beyer d1f087eb57 Change libimag{bookmark, entrylink} external linking
...to report newly created entries, so that we can re-use these new
entries in the library-using code (for example for ID reporting).

Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2018-11-06 20:33:30 +01:00
Matthias Beyer a45691ef27 Change test output to use debug!() 2018-11-01 20:37:02 +01:00
Matthias Beyer 1f5b490dd7 Change test output to use debug!() 2018-11-01 20:37:02 +01:00
Matthias Beyer 83876b7c2c Change test output to use debug!() 2018-11-01 20:37:02 +01:00
Matthias Beyer 366ca62eb9 Update dependency: mdcat: 0.8 -> 0.11 2018-10-31 17:15:29 +01:00
Matthias Beyer a1c65603dc libimagentrydatetime: Move from error-chain to failure
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2018-10-30 18:46:28 +01:00
Matthias Beyer f3e7f677b0 libimagentryutil: Move from error-chain to failure
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2018-10-30 18:46:28 +01:00
Matthias Beyer e553d20a8f libimagentrymarkdown: Move from error-chain to failure
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2018-10-30 18:46:28 +01:00
Matthias Beyer ebe2a9a110 libimagentryview: Move from error-chain to failure
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2018-10-30 18:46:28 +01:00
Matthias Beyer 9b48dc27cd libimagentryref: Move from error-chain to failure
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2018-10-30 18:46:28 +01:00
Matthias Beyer 5a7def4c8e libimagentryedit: Move from error-chain to failure
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2018-10-30 18:46:28 +01:00
Matthias Beyer 7f04eb2bff libimagentrygps: Move from error-chain to failure
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2018-10-30 18:46:28 +01:00
Matthias Beyer 0cbc6741a7 libimagentrytag: Move from error-chain to failure
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2018-10-30 18:46:28 +01:00
Matthias Beyer 32e8c43ccb libimagentrylink: Move from error-chain to failure
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2018-10-30 18:46:28 +01:00
Matthias Beyer 7357f1c985 libimagentryannotation: Move from error-chain to failure
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2018-10-30 18:46:28 +01:00
Matthias Beyer a8daeb851d libimagentrycategory: Move from error-chain to failure
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2018-10-30 18:46:28 +01:00
Matthias Beyer 49ec0702fd libimagentryfilter: Move from error-chain to failure
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2018-10-30 18:46:28 +01:00
Matthias Beyer a0730c0ca9 Roll back mdcat update
Because 0.8 -> 0.10 has changed the API, we cannot update trivially.
Revert the update because of that.
2018-10-06 12:22:15 +02:00
Matthias Beyer 5d901ae411 Update dependencies
regex: 0.2 -> 1
semver: 0.8 -> 0.9
2018-10-06 12:22:15 +02:00
Matthias Beyer 0069463e46 Update dependencies
mdcat: 0.8 -> 0.10
textwrap: 0.9 -> 0.10
2018-10-06 12:21:20 +02:00