Compare commits

...

8 Commits

Author SHA1 Message Date
Sascha Ißbrücker
58836c3c76 Bump version 2021-02-18 22:11:09 +01:00
Sascha Ißbrücker
b7a8f9e53d Mark optional fields in bookmark serializer (#78) 2021-02-18 22:02:45 +01:00
Sascha Ißbrücker
afe081d3b5 Update CHANGELOG.md 2021-02-18 07:39:40 +01:00
Sascha Ißbrücker
7a14c6e2d1 Bump version 2021-02-18 07:27:31 +01:00
Sascha Ißbrücker
f7e6fbc588 Fix archive endpoints (#77) 2021-02-18 07:14:44 +01:00
Sascha Ißbrücker
778f1b2ff3 Remove legacy API (#55) 2021-02-16 04:45:21 +01:00
Sascha Ißbrücker
79dd4179d2 Add archive endpoints 2021-02-16 04:24:22 +01:00
Sascha Ißbrücker
0980e6a2b2 Update CHANGELOG.md 2021-02-15 21:11:56 +01:00
10 changed files with 69 additions and 34 deletions

18
API.md
View File

@@ -59,7 +59,7 @@ Example response:
} }
``` ```
**Archived** **List Archived**
``` ```
GET /api/bookmarks/archived/ GET /api/bookmarks/archived/
@@ -121,6 +121,22 @@ Example payload:
} }
``` ```
**Archive**
```
POST /api/bookmarks/<id>/archive/
```
Archives a bookmark.
**Unarchive**
```
POST /api/bookmarks/<id>/unarchive/
```
Unarchives a bookmark.
**Delete** **Delete**
``` ```

View File

@@ -1,5 +1,16 @@
# Changelog # Changelog
## v1.3.2 (18/02/2021)
- [**closed**] /archive and /unarchive API routes return 404 [#77](https://github.com/sissbruecker/linkding/issues/77)
- [**closed**] API - /api/check_url?url= with token authetification [#55](https://github.com/sissbruecker/linkding/issues/55)
---
## v1.3.1 (15/02/2021)
[enhancement] Enhance delete links with inline confirmation
---
## v1.3.0 (14/02/2021) ## v1.3.0 (14/02/2021)
- [**closed**] Novice help. [#71](https://github.com/sissbruecker/linkding/issues/71) - [**closed**] Novice help. [#71](https://github.com/sissbruecker/linkding/issues/71)
- [**closed**] Option to create bookmarks public [#70](https://github.com/sissbruecker/linkding/issues/70) - [**closed**] Option to create bookmarks public [#70](https://github.com/sissbruecker/linkding/issues/70)

View File

@@ -1,3 +1,4 @@
from django.urls import reverse
from rest_framework import viewsets, mixins, status from rest_framework import viewsets, mixins, status
from rest_framework.decorators import action from rest_framework.decorators import action
from rest_framework.response import Response from rest_framework.response import Response
@@ -6,6 +7,8 @@ from rest_framework.routers import DefaultRouter
from bookmarks import queries from bookmarks import queries
from bookmarks.api.serializers import BookmarkSerializer, TagSerializer from bookmarks.api.serializers import BookmarkSerializer, TagSerializer
from bookmarks.models import Bookmark, Tag from bookmarks.models import Bookmark, Tag
from bookmarks.services.bookmarks import archive_bookmark, unarchive_bookmark
from bookmarks.services.website_loader import load_website_metadata
class BookmarkViewSet(viewsets.GenericViewSet, class BookmarkViewSet(viewsets.GenericViewSet,
@@ -39,6 +42,37 @@ class BookmarkViewSet(viewsets.GenericViewSet,
data = serializer(page, many=True).data data = serializer(page, many=True).data
return self.get_paginated_response(data) return self.get_paginated_response(data)
@action(methods=['post'], detail=True)
def archive(self, request, pk):
bookmark = self.get_object()
archive_bookmark(bookmark)
return Response(status=status.HTTP_204_NO_CONTENT)
@action(methods=['post'], detail=True)
def unarchive(self, request, pk):
bookmark = self.get_object()
unarchive_bookmark(bookmark)
return Response(status=status.HTTP_204_NO_CONTENT)
@action(methods=['get'], detail=False)
def check(self, request):
url = request.GET.get('url')
bookmark = Bookmark.objects.filter(owner=request.user, url=url).first()
existing_bookmark_data = None
if bookmark is not None:
existing_bookmark_data = {
'id': bookmark.id,
'edit_url': reverse('bookmarks:edit', args=[bookmark.id])
}
metadata = load_website_metadata(url)
return Response({
'bookmark': existing_bookmark_data,
'metadata': metadata.to_dict()
}, status=status.HTTP_200_OK)
class TagViewSet(viewsets.GenericViewSet, class TagViewSet(viewsets.GenericViewSet,
mixins.ListModelMixin, mixins.ListModelMixin,

View File

@@ -30,8 +30,11 @@ class BookmarkSerializer(serializers.ModelSerializer):
'date_modified' 'date_modified'
] ]
# Override optional char fields to provide default value
title = serializers.CharField(required=False, allow_blank=True, default='')
description = serializers.CharField(required=False, allow_blank=True, default='')
# Override readonly tag_names property to allow passing a list of tag names to create/update # Override readonly tag_names property to allow passing a list of tag names to create/update
tag_names = TagListField() tag_names = TagListField(required=False, default=[])
def create(self, validated_data): def create(self, validated_data):
bookmark = Bookmark() bookmark = Bookmark()

View File

@@ -97,7 +97,7 @@
toggleIcon(descriptionInput, true); toggleIcon(descriptionInput, true);
const websiteUrl = encodeURIComponent(urlInput.value); const websiteUrl = encodeURIComponent(urlInput.value);
const requestUrl = `{% url 'bookmarks:api.check_url' %}?url=${websiteUrl}`; const requestUrl = `{% url 'bookmarks:api-root' %}bookmarks/check?url=${websiteUrl}`;
fetch(requestUrl) fetch(requestUrl)
.then(response => response.json()) .then(response => response.json())
.then(data => { .then(data => {

View File

@@ -23,6 +23,5 @@ urlpatterns = [
path('settings/import', views.settings.bookmark_import, name='settings.import'), path('settings/import', views.settings.bookmark_import, name='settings.import'),
path('settings/export', views.settings.bookmark_export, name='settings.export'), path('settings/export', views.settings.bookmark_export, name='settings.export'),
# API # API
path('api/check_url', views.api.check_url, name='api.check_url'),
path('api/', include(router.urls), name='api') path('api/', include(router.urls), name='api')
] ]

View File

@@ -1,3 +1,2 @@
from .api import *
from .bookmarks import * from .bookmarks import *
from .settings import * from .settings import *

View File

@@ -1,27 +0,0 @@
from django.contrib.auth.decorators import login_required
from django.forms import model_to_dict
from django.http import JsonResponse
from django.urls import reverse
from bookmarks.services.website_loader import load_website_metadata
from bookmarks.models import Bookmark
@login_required
def check_url(request):
url = request.GET.get('url')
bookmark = Bookmark.objects.filter(owner=request.user, url=url).first()
existing_bookmark_data = None
if bookmark is not None:
existing_bookmark_data = {
'id': bookmark.id,
'edit_url': reverse('bookmarks:edit', args=[bookmark.id])
}
metadata = load_website_metadata(url)
return JsonResponse({
'bookmark': existing_bookmark_data,
'metadata': metadata.to_dict()
})

View File

@@ -1,6 +1,6 @@
{ {
"name": "linkding", "name": "linkding",
"version": "1.3.1", "version": "1.3.3",
"description": "", "description": "",
"main": "index.js", "main": "index.js",
"scripts": { "scripts": {

View File

@@ -1 +1 @@
1.3.1 1.3.3