42links

Check-in [2a9bb6307d]
Login

Check-in [2a9bb6307d]

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:reduced progn()s, fixed copy&paste mistakes
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | release-1.1.2 | trunk
Files: files | file ages | folders
SHA3-256: 2a9bb6307d60e28d70b1603c0ffaa61749cb71c02e0102749d955ec5615b6923
User & Date: Cthulhux 2025-02-17 12:44:48
Context
2025-02-17
12:44
reduced progn()s, fixed copy&paste mistakes Leaf check-in: 2a9bb6307d user: Cthulhux tags: release-1.1.2, trunk
2025-02-14
11:43
1.1.0 broke tag comparison. 1.1.1 should fix it. check-in: 2beec976b7 user: Cthulhux tags: release-1.1.1, trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to 42links.asd.

1
2
3
4
5
6
7
8
9
10
(asdf:defsystem "42links"
  :description "A simple bookmarking service."
  :version "1.1.1"
  :author "tux0r"
  :entry-point "42links:main"
  :license "BSD-3-Clause-No-Military-License"
  :components ((:module "hismetic"
                :components
                      ((:file "hismetic")))
               (:module "src"


|







1
2
3
4
5
6
7
8
9
10
(asdf:defsystem "42links"
  :description "A simple bookmarking service."
  :version "1.1.2"
  :author "tux0r"
  :entry-point "42links:main"
  :license "BSD-3-Clause-No-Military-License"
  :components ((:module "hismetic"
                :components
                      ((:file "hismetic")))
               (:module "src"

Changes to LICENSE.

1
2
3
4
5
6
7
8
9

Copyright (c) 2024 tux0r. All Rights Reserved.

Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:

 1. Redistribution of source code must retain the above copyright notice, this
    list of conditions and the following disclaimer.

<
|








1
2
3
4
5
6
7
8

Copyright (c) 2025 tux0r. All Rights Reserved.

Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:

 1. Redistribution of source code must retain the above copyright notice, this
    list of conditions and the following disclaimer.

Changes to src/api.lisp.

28
29
30
31
32
33
34
35

36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
        ;; Login failed.
        (with-output-to-string (s)
          (jzon:with-writer* (:stream s :pretty t)
            (jzon:with-object*
                (progn ()
                       (jzon:write-property* :success nil)
                       (jzon:write-property* :message "Erroneous log-in data.")))))
        (progn

          (let ((can-use-api (get-user-setting "api-enabled" user-name t)))
            (if (not can-use-api)
                ;; Well...
                (with-output-to-string (s)
                  (jzon:with-writer* (:stream s :pretty t)
                    (jzon:with-object*
                        (progn ()
                               (jzon:write-property* :success nil)
                               (jzon:write-property* :message "API access for this user is disabled!")))))
                
                ;; Else:
                (progn
                  (with-output-to-string (s)
                    (jzon:with-writer* (:stream s :pretty t)
                      (jzon:with-object*
                          (switch (api-method :test 'equal)
                                  ("list-links"
                                   ;; Return the list of links.
                                   (progn ()
                                          (jzon:write-property* :success t)
                                          (jzon:write-property* :message "The list of links has been requested successfully.")
                                          
                                          (jzon:write-key* :links)
                                          (jzon:with-array*
                                              (let ((search-terms (cdr (assoc "filter" post-body :test #'equal))))
                                                (if search-terms
                                                    ;; With or without a filter?
                                                    (loop for link in (get-searched-links user-name search-terms)
                                                          do
                                                             (jzon:write-value* (alist-hash-table link)))
                                                    (loop for link in (get-all-links user-name)
                                                          do
                                                             (jzon:write-value* (alist-hash-table link))))))))
                                  ("add-links"
                                   ;; Add a few links.
                                   (let ((linkdata (cdr (assoc "linkdata" post-body :test #'equal)))
                                         (success 0)
                                         (errors 0))
                                     (if (not linkdata)
                                         (progn ()
                                                (jzon:write-property* :success nil)
                                                (jzon:write-property* :message "No link data were sent - no links will be added"))

                                         ;; Add a link:
                                         (progn ()
                                                (loop for link in linkdata
                                                      do
                                                         (if (add-or-edit-link link)
                                                             (incf errors)
                                                             (incf success)))
                                                
                                                ;; Write stats:
                                                (if (= success 0)
                                                    (progn ()
                                                           (jzon:write-property* :success nil)
                                                           (jzon:write-property* :message "No link could be inserted. Check your request data and try again."))
                                                    (progn ()
                                                           (jzon:write-property* :success t)
                                                           (jzon:write-property* :message (format nil "~D of ~D links were added to your database (~D invalid)." success (+ errors success) errors))))))))
                                  ("delete-links"
                                   ;; Delete a few links.
                                   (let ((linkdata (cdr (assoc "deleteuids" post-body :test #'equal)))
                                         (success 0)
                                         (errors 0))
                                     (if (not linkdata)
                                         (progn ()
                                                (jzon:write-property* :success nil)
                                                (jzon:write-property* :message "No link data were sent - no links will be deleted"))

                                         ;; Add a link:
                                         (progn ()
                                                (loop for link in linkdata
                                                      do
                                                         ;; Check whether the link (= UID) is one of the user's:
                                                         (if (not (postmodern:query (:select 'uid :from 'links :where (:and
                                                                                                                       (:= 'uid link)
                                                                                                                       (:= 'user-uid (:select 'uid :from 'users :where (:= 'name user-name)))))
                                                                                    :single))
                                                             (incf errors)

                                                             ;; It is:
                                                             (progn ()
                                                                    (delete-link link)
                                                                    (incf success))))
                                                
                                                ;; Write stats:
                                                (if (= success 0)
                                                    (progn ()
                                                           (jzon:write-property* :success nil)
                                                           (jzon:write-property* :message "No link could be deleted. Check your request data and try again."))
                                                    (progn ()
                                                           (jzon:write-property* :success t)
                                                           (jzon:write-property* :message (format nil "~D of ~D links were deleted from your database (~D not found)." success (+ errors success) errors)))))))))))))))))))







|
>
|
|
|
|
|
|
|
|
|
|
|
<
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|

|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|

|
|
|
|
|
|
|
|
|
|

|
|
|
|
|
|
|
|
|
|
|
|
|
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47

48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
        ;; Login failed.
        (with-output-to-string (s)
          (jzon:with-writer* (:stream s :pretty t)
            (jzon:with-object*
                (progn ()
                       (jzon:write-property* :success nil)
                       (jzon:write-property* :message "Erroneous log-in data.")))))

        ;; Login successful.
        (let ((can-use-api (get-user-setting "api-enabled" user-name t)))
          (if (not can-use-api)
             ;; Well...
             (with-output-to-string (s)
               (jzon:with-writer* (:stream s :pretty t)
                  (jzon:with-object*
                      (progn ()
                             (jzon:write-property* :success nil)
                             (jzon:write-property* :message "API access for this user is disabled!")))))
              
              ;; Else:

              (with-output-to-string (s)
                (jzon:with-writer* (:stream s :pretty t)
                  (jzon:with-object*
                      (switch (api-method :test 'equal)
                              ("list-links"
                               ;; Return the list of links.
                               (progn ()
                                      (jzon:write-property* :success t)
                                      (jzon:write-property* :message "The list of links has been requested successfully.")
                                      
                                      (jzon:write-key* :links)
                                      (jzon:with-array*
                                          (let ((search-terms (cdr (assoc "filter" post-body :test #'equal))))
                                            (if search-terms
                                                ;; With or without a filter?
                                                (loop for link in (get-searched-links user-name search-terms)
                                                      do
                                                         (jzon:write-value* (alist-hash-table link)))
                                                (loop for link in (get-all-links user-name)
                                                      do
                                                         (jzon:write-value* (alist-hash-table link))))))))
                              ("add-links"
                               ;; Add a few links.
                               (let ((linkdata (cdr (assoc "linkdata" post-body :test #'equal)))
                                     (success 0)
                                     (errors 0))
                                 (if (not linkdata)
                                     (progn ()
                                            (jzon:write-property* :success nil)
                                            (jzon:write-property* :message "No link data were sent - no links will be added"))

                                     ;; Add a link:
                                     (progn ()
                                            (loop for link in linkdata
                                                  do
                                                     (if (add-or-edit-link link)
                                                         (incf errors)
                                                         (incf success)))
                                            
                                            ;; Write stats:
                                            (if (= success 0)
                                                (progn ()
                                                       (jzon:write-property* :success nil)
                                                       (jzon:write-property* :message "No link could be inserted. Check your request data and try again."))
                                                (progn ()
                                                       (jzon:write-property* :success t)
                                                       (jzon:write-property* :message (format nil "~D of ~D links were added to your database (~D invalid)." success (+ errors success) errors))))))))
                              ("delete-links"
                               ;; Delete a few links.
                               (let ((linkdata (cdr (assoc "deleteuids" post-body :test #'equal)))
                                     (success 0)
                                     (errors 0))
                                 (if (not linkdata)
                                     (progn ()
                                            (jzon:write-property* :success nil)
                                            (jzon:write-property* :message "No link data were sent - no links will be deleted"))

                                     ;; Add a link:
                                     (progn ()
                                            (loop for link in linkdata
                                                  do
                                                     ;; Check whether the link (= UID) is one of the user's:
                                                     (if (not (postmodern:query (:select 'uid :from 'links :where (:and
                                                                                                                   (:= 'uid link)
                                                                                                                   (:= 'user-uid (:select 'uid :from 'users :where (:= 'name user-name)))))
                                                                                :single))
                                                         (incf errors)

                                                         ;; It is:
                                                         (progn ()
                                                                (delete-link link)
                                                                (incf success))))
                                            
                                            ;; Write stats:
                                            (if (= success 0)
                                                (progn ()
                                                       (jzon:write-property* :success nil)
                                                       (jzon:write-property* :message "No link could be deleted. Check your request data and try again."))
                                                (progn ()
                                                       (jzon:write-property* :success t)
                                                       (jzon:write-property* :message (format nil "~D of ~D links were deleted from your database (~D not found)." success (+ errors success) errors)))))))))))))))))

Changes to src/static/site.webmanifest.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
{
  "name": "MyWebSite",
  "short_name": "MySite",
  "icons": [
    {
      "src": "/web-app-manifest-192x192.png",
      "sizes": "192x192",
      "type": "image/png",
      "purpose": "maskable"
    },
    {
      "src": "/web-app-manifest-512x512.png",
      "sizes": "512x512",
      "type": "image/png",
      "purpose": "maskable"
    }
  ],
  "theme_color": "#ffffff",
  "background_color": "#ffffff",

|
|


|





|







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
{
  "name": "42links",
  "short_name": "42links",
  "icons": [
    {
      "src": "/static/web-app-manifest-192x192.png",
      "sizes": "192x192",
      "type": "image/png",
      "purpose": "maskable"
    },
    {
      "src": "/static/web-app-manifest-512x512.png",
      "sizes": "512x512",
      "type": "image/png",
      "purpose": "maskable"
    }
  ],
  "theme_color": "#ffffff",
  "background_color": "#ffffff",