Skip to content

Commit

Permalink
doc: update doc
Browse files Browse the repository at this point in the history
  • Loading branch information
mutantsan committed Oct 24, 2024
1 parent 29c2616 commit f75ec6f
Show file tree
Hide file tree
Showing 8 changed files with 203 additions and 134 deletions.
63 changes: 3 additions & 60 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

This extension will capture and retain a comprehensive record of all changes within a CKAN app.

Read the [documentation](https://datashades.github.io/ckanext-event-audit/) for a full user guide.

## Developer installation

To install ckanext-event-audit for development, activate your CKAN virtualenv and
Expand All @@ -14,66 +16,6 @@ do:
pip install -e .
pip install -r dev-requirements.txt


## Register new repositories

There are few repositories available by default, but you can register new repositories to store the events. Think of it as a way to store the events in different databases or services. We don't want to limit the extension to a specific storage. The main idea is to provide a way to store, retrieve, and filter the events.

To register a new repository, you need to define a repository class and register it.

### Defining the repository class

To register a new repository, you need to define a repository class that inherits from `AbstractRepository` and implements the following methods: `write_event`, `get_event`, and `filter_events`.

For example:

```python
from ckanext.event_audit.repositories import AbstractRepository
from ckanext.event_audit import types


class MyRepository(AbstractRepository):
name = "my_repository"

@classmethod
def get_name(cls) -> str:
return "my_repository"

def write_event(self, event: types.Event) -> types.WriteStatus:
pass

def get_event(self, event_id: str) -> types.Event | None:
pass

def filter_events(self, filters: types.Filters) -> list[types.Event]:
pass
```

See the existing repositories as examples (`ckanext/event_audit/repositories/`).

### Registering the repository

To register the new repository, you need to use a IEventAudit interface and the `register_repository` method.

For example:

```python
from ckanext.event_audit.interfaces import IEventAudit
from ckanext.your_extension.repositories import MyRepository

class MyRepositoryPlugin(plugins.SingletonPlugin):
...
plugins.implements(IEventAudit, inherit=True)

# IEventAudit

def register_repository(self) -> dict[str, type[AbstractRepository]]:
return {
MyRepository.get_name(): MyRepository,
}
```


## Tests

To run the tests, do:
Expand All @@ -83,3 +25,4 @@ To run the tests, do:
## License

[AGPL](https://www.gnu.org/licenses/agpl-3.0.en.html)

62 changes: 60 additions & 2 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@

This extension will capture and retain a comprehensive record of all changes within a CKAN app.

Read the [documentation](https://datashades.github.io/ckanext-event-audit/) for a full user guide.

## Developer installation

To install ckanext-event-audit for development, activate your CKAN virtualenv and
Expand All @@ -16,6 +14,66 @@ do:
pip install -e .
pip install -r dev-requirements.txt


## Register new repositories

There are few repositories available by default, but you can register new repositories to store the events. Think of it as a way to store the events in different databases or services. We don't want to limit the extension to a specific storage. The main idea is to provide a way to store, retrieve, and filter the events.

To register a new repository, you need to define a repository class and register it.

### Defining the repository class

To register a new repository, you need to define a repository class that inherits from `AbstractRepository` and implements the following methods: `write_event`, `get_event`, and `filter_events`.

For example:

```python
from ckanext.event_audit.repositories import AbstractRepository
from ckanext.event_audit import types


class MyRepository(AbstractRepository):
name = "my_repository"

@classmethod
def get_name(cls) -> str:
return "my_repository"

def write_event(self, event: types.Event) -> types.WriteStatus:
pass

def get_event(self, event_id: str) -> types.Event | None:
pass

def filter_events(self, filters: types.Filters) -> list[types.Event]:
pass
```

See the existing repositories as examples (`ckanext/event_audit/repositories/`).

### Registering the repository

To register the new repository, you need to use a IEventAudit interface and the `register_repository` method.

For example:

```python
from ckanext.event_audit.interfaces import IEventAudit
from ckanext.your_extension.repositories import MyRepository

class MyRepositoryPlugin(plugins.SingletonPlugin):
...
plugins.implements(IEventAudit, inherit=True)

# IEventAudit

def register_repository(self) -> dict[str, type[AbstractRepository]]:
return {
MyRepository.get_name(): MyRepository,
}
```


## Tests

To run the tests, do:
Expand Down
7 changes: 3 additions & 4 deletions mkdocs.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
site_name: ckanext-popo
site_url: https://.github.io/ckanext-popo/
site_name: ckanext-event-audit
site_url: https://.github.io/ckanext-event-audit/

repo_url: https://github.com//ckanext-popo
repo_url: https://github.com//ckanext-event-audit

markdown_extensions:
- pymdownx.snippets # include code snippets
Expand Down Expand Up @@ -74,4 +74,3 @@ theme:

nav:
- index.md
- hui.md
54 changes: 17 additions & 37 deletions site/404.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,19 @@



<link rel="icon" href="/ckanext-popo/img/favicon.ico">
<link rel="icon" href="/ckanext-event-audit/img/favicon.ico">
<meta name="generator" content="mkdocs-1.6.1, mkdocs-material-9.5.42">



<title>ckanext-popo</title>
<title>ckanext-event-audit</title>



<link rel="stylesheet" href="/ckanext-popo/assets/stylesheets/main.0253249f.min.css">
<link rel="stylesheet" href="/ckanext-event-audit/assets/stylesheets/main.0253249f.min.css">


<link rel="stylesheet" href="/ckanext-popo/assets/stylesheets/palette.06af60db.min.css">
<link rel="stylesheet" href="/ckanext-event-audit/assets/stylesheets/palette.06af60db.min.css">



Expand All @@ -42,9 +42,9 @@



<link rel="stylesheet" href="/ckanext-popo/assets/_mkdocstrings.css">
<link rel="stylesheet" href="/ckanext-event-audit/assets/_mkdocstrings.css">

<script>__md_scope=new URL("/ckanext-popo/",location),__md_hash=e=>[...e].reduce(((e,_)=>(e<<5)-e+_.charCodeAt(0)),0),__md_get=(e,_=localStorage,t=__md_scope)=>JSON.parse(_.getItem(t.pathname+"."+e)),__md_set=(e,_,t=localStorage,a=__md_scope)=>{try{t.setItem(a.pathname+"."+e,JSON.stringify(_))}catch(e){}}</script>
<script>__md_scope=new URL("/ckanext-event-audit/",location),__md_hash=e=>[...e].reduce(((e,_)=>(e<<5)-e+_.charCodeAt(0)),0),__md_get=(e,_=localStorage,t=__md_scope)=>JSON.parse(_.getItem(t.pathname+"."+e)),__md_set=(e,_,t=localStorage,a=__md_scope)=>{try{t.setItem(a.pathname+"."+e,JSON.stringify(_))}catch(e){}}</script>



Expand Down Expand Up @@ -81,9 +81,9 @@

<header class="md-header md-header--shadow" data-md-component="header">
<nav class="md-header__inner md-grid" aria-label="Header">
<a href="/ckanext-popo/." title="ckanext-popo" class="md-header__button md-logo" aria-label="ckanext-popo" data-md-component="logo">
<a href="/ckanext-event-audit/." title="ckanext-event-audit" class="md-header__button md-logo" aria-label="ckanext-event-audit" data-md-component="logo">

<img src="/ckanext-popo/img/logo.png" alt="logo">
<img src="/ckanext-event-audit/img/logo.png" alt="logo">

</a>
<label class="md-header__button md-icon" for="__drawer">
Expand All @@ -94,7 +94,7 @@
<div class="md-header__ellipsis">
<div class="md-header__topic">
<span class="md-ellipsis">
ckanext-popo
ckanext-event-audit
</span>
</div>
<div class="md-header__topic" data-md-component="header-topic">
Expand Down Expand Up @@ -187,7 +187,7 @@


<div class="md-header__source">
<a href="https://github.com//ckanext-popo" title="Go to repository" class="md-source" data-md-component="source">
<a href="https://github.com//ckanext-event-audit" title="Go to repository" class="md-source" data-md-component="source">
<div class="md-source__icon md-icon">

<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512"><!--! Font Awesome Free 6.6.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) Copyright 2024 Fonticons, Inc.--><path d="M439.55 236.05 244 40.45a28.87 28.87 0 0 0-40.81 0l-40.66 40.63 51.52 51.52c27.06-9.14 52.68 16.77 43.39 43.68l49.66 49.66c34.23-11.8 61.18 31 35.47 56.69-26.49 26.49-70.21-2.87-56-37.34L240.22 199v121.85c25.3 12.54 22.26 41.85 9.08 55a34.34 34.34 0 0 1-48.55 0c-17.57-17.6-11.07-46.91 11.25-56v-123c-20.8-8.51-24.6-30.74-18.64-45L142.57 101 8.45 235.14a28.86 28.86 0 0 0 0 40.81l195.61 195.6a28.86 28.86 0 0 0 40.8 0l194.69-194.69a28.86 28.86 0 0 0 0-40.81"/></svg>
Expand Down Expand Up @@ -223,16 +223,16 @@

<nav class="md-nav md-nav--primary" aria-label="Navigation" data-md-level="0">
<label class="md-nav__title" for="__drawer">
<a href="/ckanext-popo/." title="ckanext-popo" class="md-nav__button md-logo" aria-label="ckanext-popo" data-md-component="logo">
<a href="/ckanext-event-audit/." title="ckanext-event-audit" class="md-nav__button md-logo" aria-label="ckanext-event-audit" data-md-component="logo">

<img src="/ckanext-popo/img/logo.png" alt="logo">
<img src="/ckanext-event-audit/img/logo.png" alt="logo">

</a>
ckanext-popo
ckanext-event-audit
</label>

<div class="md-nav__source">
<a href="https://github.com//ckanext-popo" title="Go to repository" class="md-source" data-md-component="source">
<a href="https://github.com//ckanext-event-audit" title="Go to repository" class="md-source" data-md-component="source">
<div class="md-source__icon md-icon">

<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512"><!--! Font Awesome Free 6.6.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) Copyright 2024 Fonticons, Inc.--><path d="M439.55 236.05 244 40.45a28.87 28.87 0 0 0-40.81 0l-40.66 40.63 51.52 51.52c27.06-9.14 52.68 16.77 43.39 43.68l49.66 49.66c34.23-11.8 61.18 31 35.47 56.69-26.49 26.49-70.21-2.87-56-37.34L240.22 199v121.85c25.3 12.54 22.26 41.85 9.08 55a34.34 34.34 0 0 1-48.55 0c-17.57-17.6-11.07-46.91 11.25-56v-123c-20.8-8.51-24.6-30.74-18.64-45L142.57 101 8.45 235.14a28.86 28.86 0 0 0 0 40.81l195.61 195.6a28.86 28.86 0 0 0 40.8 0l194.69-194.69a28.86 28.86 0 0 0 0-40.81"/></svg>
Expand All @@ -252,7 +252,7 @@


<li class="md-nav__item">
<a href="/ckanext-popo/." class="md-nav__link">
<a href="/ckanext-event-audit/." class="md-nav__link">


<span class="md-ellipsis">
Expand All @@ -265,26 +265,6 @@









<li class="md-nav__item">
<a href="/ckanext-popo/hui.md" class="md-nav__link">


<span class="md-ellipsis">
None
</span>


</a>
</li>



</ul>
</nav>
</div>
Expand Down Expand Up @@ -358,10 +338,10 @@ <h1>404 - Not found</h1>
<div class="md-progress" data-md-component="progress" role="progressbar"></div>


<script id="__config" type="application/json">{"base": "/ckanext-popo/", "features": ["navigation.instant", "navigation.instant.prefetch", "navigation.instant.progress", "navigation.footer", "navigation.indexes", "navigation.top", "content.code.copy", "content.code.select", "content.code.annotate"], "search": "/ckanext-popo/assets/javascripts/workers/search.6ce7567c.min.js", "translations": {"clipboard.copied": "Copied to clipboard", "clipboard.copy": "Copy to clipboard", "search.result.more.one": "1 more on this page", "search.result.more.other": "# more on this page", "search.result.none": "No matching documents", "search.result.one": "1 matching document", "search.result.other": "# matching documents", "search.result.placeholder": "Type to start searching", "search.result.term.missing": "Missing", "select.version": "Select version"}}</script>
<script id="__config" type="application/json">{"base": "/ckanext-event-audit/", "features": ["navigation.instant", "navigation.instant.prefetch", "navigation.instant.progress", "navigation.footer", "navigation.indexes", "navigation.top", "content.code.copy", "content.code.select", "content.code.annotate"], "search": "/ckanext-event-audit/assets/javascripts/workers/search.6ce7567c.min.js", "translations": {"clipboard.copied": "Copied to clipboard", "clipboard.copy": "Copy to clipboard", "search.result.more.one": "1 more on this page", "search.result.more.other": "# more on this page", "search.result.none": "No matching documents", "search.result.one": "1 matching document", "search.result.other": "# matching documents", "search.result.placeholder": "Type to start searching", "search.result.term.missing": "Missing", "select.version": "Select version"}}</script>


<script src="/ckanext-popo/assets/javascripts/bundle.83f73b43.min.js"></script>
<script src="/ckanext-event-audit/assets/javascripts/bundle.83f73b43.min.js"></script>


</body>
Expand Down
Loading

0 comments on commit f75ec6f

Please sign in to comment.