├── .dockerignore ├── .eslintignore ├── .eslintrc.js ├── .github ├── dependabot.yml └── workflows │ ├── docker.yaml │ └── test.yaml ├── .gitignore ├── Dockerfile ├── LICENSE ├── README.md ├── api ├── datafiles │ └── .gitignore ├── etag-middleware.js ├── index.js └── utils.js ├── assets └── zazuko │ ├── 404-layout.scss │ ├── footer.scss │ ├── general.scss │ ├── home-layout.scss │ ├── main.scss │ ├── md-content.scss │ ├── reset.scss │ ├── search-result.scss │ └── topbar.scss ├── build-resources.js ├── components ├── Autocomplete.vue ├── CurlExample.vue ├── DetailResults.vue ├── MainResults.vue ├── PageFooter.vue ├── PageHeader.vue ├── Predicate.vue ├── Term.vue └── Terms.vue ├── cypress.json ├── layouts ├── default.vue └── error.vue ├── nuxt.config.js ├── package-lock.json ├── package.json ├── pages ├── _.vue ├── about.vue ├── api.vue ├── namespaces.vue ├── prefix │ └── _.vue ├── prefixes.vue └── search.vue ├── plugins └── clipboard.js ├── snapshots.js ├── static ├── favicon │ ├── android-chrome-192x192.png │ ├── android-chrome-512x512.png │ ├── apple-touch-icon.png │ ├── favicon-16x16.png │ ├── favicon-32x32.png │ ├── favicon.ico │ └── site.webmanifest ├── og-home.png ├── opensearch.xml ├── prefix-server-logo.svg └── zazuko-logo.svg └── test └── e2e ├── integration ├── api_spec.js ├── home_spec.js ├── prefixes_spec.js └── search_spec.js ├── plugins └── index.js └── support └── index.js /.dockerignore: -------------------------------------------------------------------------------- 1 | /node_modules 2 | /.nuxt 3 | /api/datafiles/* 4 | Dockerfile 5 | -------------------------------------------------------------------------------- /.eslintignore: -------------------------------------------------------------------------------- 1 | /snapshots.js 2 | -------------------------------------------------------------------------------- /.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | root: true, 3 | env: { 4 | browser: true, 5 | node: true, 6 | 'cypress/globals': true 7 | }, 8 | plugins: [ 9 | 'vue', 10 | 'cypress' 11 | ], 12 | extends: [ 13 | '@nuxtjs', 14 | 'plugin:nuxt/recommended', 15 | 'plugin:vue/strongly-recommended', 16 | 'plugin:cypress/recommended', 17 | 'standard' 18 | ], 19 | // add your custom rules here 20 | rules: { 21 | 'no-console': 1, 22 | 'vue/require-prop-types': 0, 23 | 'vue/html-self-closing': 0, 24 | 'vue/component-name-in-template-casing': ['error', 'kebab-case'], 25 | 'vue/singleline-html-element-content-newline': 0, 26 | 'vue/multiline-html-element-content-newline': 0, 27 | 'vue/html-closing-bracket-newline': ['error', { 28 | singleline: 'never', 29 | multiline: 'never' 30 | }], 31 | // allow async-await 32 | 'generator-star-spacing': 'off', 33 | // allow debugger during development 34 | 'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off', 35 | 'no-lonely-if': 'error', 36 | quotes: ['error', 'single', { avoidEscape: true }], 37 | 'callback-return': ['error', ['done', 'callback', 'cb', 'send']], 38 | 'object-shorthand': 'error', 39 | 'no-multi-spaces': ['error', { ignoreEOLComments: true }], 40 | 'brace-style': ['error', 'stroustrup', { allowSingleLine: false }], 41 | curly: ['error', 'all'] 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | updates: 3 | - package-ecosystem: "npm" 4 | ignore: 5 | - dependency-name: "nuxt" 6 | versions: [ ">=3.0.0" ] 7 | - dependency-name: "webpack" 8 | versions: [ ">=5.0.0" ] 9 | -------------------------------------------------------------------------------- /.github/workflows/docker.yaml: -------------------------------------------------------------------------------- 1 | name: Build and push Docker image 2 | 3 | on: 4 | push: 5 | branches: 6 | - "**" 7 | - "!dependabot/**" 8 | tags: 9 | - "v*.*.*" 10 | 11 | jobs: 12 | docker: 13 | runs-on: ubuntu-latest 14 | 15 | defaults: 16 | run: 17 | shell: bash 18 | 19 | steps: 20 | - name: Checkout 21 | uses: actions/checkout@v4 22 | 23 | - name: Set up Docker Buildx 24 | uses: docker/setup-buildx-action@v3 25 | 26 | - name: Login to GitHub Container Registry 27 | uses: docker/login-action@v3 28 | with: 29 | registry: ghcr.io 30 | username: ${{ github.actor }} 31 | password: ${{ secrets.GITHUB_TOKEN }} 32 | 33 | - name: Docker meta 34 | uses: zazuko/action-docker-meta@main 35 | id: docker_meta 36 | with: 37 | images: ghcr.io/zazuko/prefix-server 38 | 39 | - name: Tag 40 | id: tag 41 | run: echo "{tag}=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT 42 | 43 | - name: Build and push Docker images 44 | id: docker_build 45 | uses: docker/build-push-action@v5 46 | with: 47 | context: . 48 | push: true 49 | file: ./Dockerfile 50 | tags: ${{ steps.docker_meta.outputs.tags }} 51 | labels: ${{ steps.docker_meta.outputs.labels }} 52 | build-args: | 53 | COMMIT=${{ github.sha }} 54 | VERSION=${{ steps.tag.outputs.tag }} 55 | platforms: | 56 | linux/amd64 57 | -------------------------------------------------------------------------------- /.github/workflows/test.yaml: -------------------------------------------------------------------------------- 1 | name: Test 2 | on: 3 | push: 4 | pull_request: 5 | 6 | jobs: 7 | test: 8 | name: E2E 9 | runs-on: ubuntu-latest 10 | steps: 11 | - name: Setup node 12 | uses: actions/setup-node@v4 13 | with: 14 | node-version: "20" 15 | 16 | - name: Checkout the code 17 | uses: actions/checkout@v3 18 | 19 | - name: Install dependencies 20 | run: npm ci 21 | 22 | - name: Build the app 23 | run: | 24 | npm run build-data 25 | NODE_ENV=production npm run build:modern 26 | 27 | - name: Run Cypress tests 28 | uses: cypress-io/github-action@v6 29 | env: 30 | NODE_ENV: production 31 | with: 32 | install: false 33 | start: npm start 34 | wait-on: "http://localhost:3000" 35 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Created by .ignore support plugin (hsz.mobi) 2 | ### Node template 3 | # Logs 4 | logs 5 | *.log 6 | npm-debug.log* 7 | yarn-debug.log* 8 | yarn-error.log* 9 | 10 | # Runtime data 11 | pids 12 | *.pid 13 | *.seed 14 | *.pid.lock 15 | 16 | # Directory for instrumented libs generated by jscoverage/JSCover 17 | lib-cov 18 | 19 | # Coverage directory used by tools like istanbul 20 | coverage 21 | 22 | # nyc test coverage 23 | .nyc_output 24 | 25 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) 26 | .grunt 27 | 28 | # Bower dependency directory (https://bower.io/) 29 | bower_components 30 | 31 | # node-waf configuration 32 | .lock-wscript 33 | 34 | # Compiled binary addons (https://nodejs.org/api/addons.html) 35 | build/Release 36 | 37 | # Dependency directories 38 | node_modules/ 39 | jspm_packages/ 40 | 41 | # TypeScript v1 declaration files 42 | typings/ 43 | 44 | # Optional npm cache directory 45 | .npm 46 | 47 | # Optional eslint cache 48 | .eslintcache 49 | 50 | # Optional REPL history 51 | .node_repl_history 52 | 53 | # Output of 'npm pack' 54 | *.tgz 55 | 56 | # Yarn Integrity file 57 | .yarn-integrity 58 | 59 | # dotenv environment variables file 60 | .env 61 | 62 | # parcel-bundler cache (https://parceljs.org/) 63 | .cache 64 | 65 | # next.js build output 66 | .next 67 | 68 | # nuxt.js build output 69 | .nuxt 70 | 71 | # Nuxt generate 72 | dist 73 | 74 | # vuepress build output 75 | .vuepress/dist 76 | 77 | # Serverless directories 78 | .serverless 79 | 80 | # IDE / Editor 81 | .idea 82 | .editorconfig 83 | 84 | # Service worker 85 | sw.* 86 | 87 | # Mac OSX 88 | .DS_Store 89 | 90 | # Cypress videos 91 | /test/e2e/videos/*.mp4 92 | 93 | # build artifacts 94 | /api/datafiles/ 95 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | # First step: build the assets 2 | FROM docker.io/library/node:20-alpine AS builder 3 | 4 | ARG VERSION 5 | ARG COMMIT 6 | ARG API_URL_BROWSER="https://prefix.zazuko.com/" 7 | 8 | RUN apk add --no-cache bash python3 make g++ git 9 | 10 | WORKDIR /src 11 | 12 | ADD package.json package-lock.json ./ 13 | # Skip Cypress binary installation 14 | ENV CYPRESS_INSTALL_BINARY="0" 15 | 16 | ADD . . 17 | 18 | RUN npm ci 19 | 20 | ENV NODE_ENV="production" 21 | # this ENV var needs to be adapted at image build time => cannot be adjusted at runtime 22 | ENV API_URL_BROWSER="${API_URL_BROWSER}" 23 | ENV APP_VERSION="${VERSION}" 24 | ENV APP_COMMIT="${COMMIT}" 25 | 26 | RUN npm run build-data 27 | RUN npm run build:modern 28 | 29 | # Second step: only install runtime dependencies 30 | FROM docker.io/library/node:20-alpine 31 | 32 | WORKDIR /src 33 | 34 | ADD . . 35 | RUN npm ci --omit=dev --no-optional 36 | 37 | # Copy the built assets from the first step 38 | COPY --from=builder /src/.nuxt/ ./.nuxt 39 | COPY --from=builder /src/api/datafiles ./api/datafiles 40 | 41 | ENV HOST="0.0.0.0" 42 | 43 | USER node 44 | 45 | ENTRYPOINT [] 46 | 47 | CMD ["npm", "run", "start"] 48 | 49 | EXPOSE 3000 50 | HEALTHCHECK CMD wget -q -O- http://localhost:3000/api/v1/health 51 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | https://prefix.zazuko.com 2 | https://github.com/zazuko/prefix-server 3 | Copyright (C) 2019 Zazuko GmbH 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU Affero General Public License as 7 | published by the Free Software Foundation, either version 3 of the 8 | License, or (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU Affero General Public License for more details. 14 | 15 | You should have received a copy of the GNU Affero General Public License 16 | along with this program. If not, see . 17 | 18 | ========================================================================== 19 | 20 | GNU AFFERO GENERAL PUBLIC LICENSE 21 | Version 3, 19 November 2007 22 | 23 | Copyright (C) 2007 Free Software Foundation, Inc. 24 | Everyone is permitted to copy and distribute verbatim copies 25 | of this license document, but changing it is not allowed. 26 | 27 | Preamble 28 | 29 | The GNU Affero General Public License is a free, copyleft license for 30 | software and other kinds of works, specifically designed to ensure 31 | cooperation with the community in the case of network server software. 32 | 33 | The licenses for most software and other practical works are designed 34 | to take away your freedom to share and change the works. By contrast, 35 | our General Public Licenses are intended to guarantee your freedom to 36 | share and change all versions of a program--to make sure it remains free 37 | software for all its users. 38 | 39 | When we speak of free software, we are referring to freedom, not 40 | price. Our General Public Licenses are designed to make sure that you 41 | have the freedom to distribute copies of free software (and charge for 42 | them if you wish), that you receive source code or can get it if you 43 | want it, that you can change the software or use pieces of it in new 44 | free programs, and that you know you can do these things. 45 | 46 | Developers that use our General Public Licenses protect your rights 47 | with two steps: (1) assert copyright on the software, and (2) offer 48 | you this License which gives you legal permission to copy, distribute 49 | and/or modify the software. 50 | 51 | A secondary benefit of defending all users' freedom is that 52 | improvements made in alternate versions of the program, if they 53 | receive widespread use, become available for other developers to 54 | incorporate. Many developers of free software are heartened and 55 | encouraged by the resulting cooperation. However, in the case of 56 | software used on network servers, this result may fail to come about. 57 | The GNU General Public License permits making a modified version and 58 | letting the public access it on a server without ever releasing its 59 | source code to the public. 60 | 61 | The GNU Affero General Public License is designed specifically to 62 | ensure that, in such cases, the modified source code becomes available 63 | to the community. It requires the operator of a network server to 64 | provide the source code of the modified version running there to the 65 | users of that server. Therefore, public use of a modified version, on 66 | a publicly accessible server, gives the public access to the source 67 | code of the modified version. 68 | 69 | An older license, called the Affero General Public License and 70 | published by Affero, was designed to accomplish similar goals. This is 71 | a different license, not a version of the Affero GPL, but Affero has 72 | released a new version of the Affero GPL which permits relicensing under 73 | this license. 74 | 75 | The precise terms and conditions for copying, distribution and 76 | modification follow. 77 | 78 | TERMS AND CONDITIONS 79 | 80 | 0. Definitions. 81 | 82 | "This License" refers to version 3 of the GNU Affero General Public License. 83 | 84 | "Copyright" also means copyright-like laws that apply to other kinds of 85 | works, such as semiconductor masks. 86 | 87 | "The Program" refers to any copyrightable work licensed under this 88 | License. Each licensee is addressed as "you". "Licensees" and 89 | "recipients" may be individuals or organizations. 90 | 91 | To "modify" a work means to copy from or adapt all or part of the work 92 | in a fashion requiring copyright permission, other than the making of an 93 | exact copy. The resulting work is called a "modified version" of the 94 | earlier work or a work "based on" the earlier work. 95 | 96 | A "covered work" means either the unmodified Program or a work based 97 | on the Program. 98 | 99 | To "propagate" a work means to do anything with it that, without 100 | permission, would make you directly or secondarily liable for 101 | infringement under applicable copyright law, except executing it on a 102 | computer or modifying a private copy. Propagation includes copying, 103 | distribution (with or without modification), making available to the 104 | public, and in some countries other activities as well. 105 | 106 | To "convey" a work means any kind of propagation that enables other 107 | parties to make or receive copies. Mere interaction with a user through 108 | a computer network, with no transfer of a copy, is not conveying. 109 | 110 | An interactive user interface displays "Appropriate Legal Notices" 111 | to the extent that it includes a convenient and prominently visible 112 | feature that (1) displays an appropriate copyright notice, and (2) 113 | tells the user that there is no warranty for the work (except to the 114 | extent that warranties are provided), that licensees may convey the 115 | work under this License, and how to view a copy of this License. If 116 | the interface presents a list of user commands or options, such as a 117 | menu, a prominent item in the list meets this criterion. 118 | 119 | 1. Source Code. 120 | 121 | The "source code" for a work means the preferred form of the work 122 | for making modifications to it. "Object code" means any non-source 123 | form of a work. 124 | 125 | A "Standard Interface" means an interface that either is an official 126 | standard defined by a recognized standards body, or, in the case of 127 | interfaces specified for a particular programming language, one that 128 | is widely used among developers working in that language. 129 | 130 | The "System Libraries" of an executable work include anything, other 131 | than the work as a whole, that (a) is included in the normal form of 132 | packaging a Major Component, but which is not part of that Major 133 | Component, and (b) serves only to enable use of the work with that 134 | Major Component, or to implement a Standard Interface for which an 135 | implementation is available to the public in source code form. A 136 | "Major Component", in this context, means a major essential component 137 | (kernel, window system, and so on) of the specific operating system 138 | (if any) on which the executable work runs, or a compiler used to 139 | produce the work, or an object code interpreter used to run it. 140 | 141 | The "Corresponding Source" for a work in object code form means all 142 | the source code needed to generate, install, and (for an executable 143 | work) run the object code and to modify the work, including scripts to 144 | control those activities. However, it does not include the work's 145 | System Libraries, or general-purpose tools or generally available free 146 | programs which are used unmodified in performing those activities but 147 | which are not part of the work. For example, Corresponding Source 148 | includes interface definition files associated with source files for 149 | the work, and the source code for shared libraries and dynamically 150 | linked subprograms that the work is specifically designed to require, 151 | such as by intimate data communication or control flow between those 152 | subprograms and other parts of the work. 153 | 154 | The Corresponding Source need not include anything that users 155 | can regenerate automatically from other parts of the Corresponding 156 | Source. 157 | 158 | The Corresponding Source for a work in source code form is that 159 | same work. 160 | 161 | 2. Basic Permissions. 162 | 163 | All rights granted under this License are granted for the term of 164 | copyright on the Program, and are irrevocable provided the stated 165 | conditions are met. This License explicitly affirms your unlimited 166 | permission to run the unmodified Program. The output from running a 167 | covered work is covered by this License only if the output, given its 168 | content, constitutes a covered work. This License acknowledges your 169 | rights of fair use or other equivalent, as provided by copyright law. 170 | 171 | You may make, run and propagate covered works that you do not 172 | convey, without conditions so long as your license otherwise remains 173 | in force. You may convey covered works to others for the sole purpose 174 | of having them make modifications exclusively for you, or provide you 175 | with facilities for running those works, provided that you comply with 176 | the terms of this License in conveying all material for which you do 177 | not control copyright. Those thus making or running the covered works 178 | for you must do so exclusively on your behalf, under your direction 179 | and control, on terms that prohibit them from making any copies of 180 | your copyrighted material outside their relationship with you. 181 | 182 | Conveying under any other circumstances is permitted solely under 183 | the conditions stated below. Sublicensing is not allowed; section 10 184 | makes it unnecessary. 185 | 186 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 187 | 188 | No covered work shall be deemed part of an effective technological 189 | measure under any applicable law fulfilling obligations under article 190 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 191 | similar laws prohibiting or restricting circumvention of such 192 | measures. 193 | 194 | When you convey a covered work, you waive any legal power to forbid 195 | circumvention of technological measures to the extent such circumvention 196 | is effected by exercising rights under this License with respect to 197 | the covered work, and you disclaim any intention to limit operation or 198 | modification of the work as a means of enforcing, against the work's 199 | users, your or third parties' legal rights to forbid circumvention of 200 | technological measures. 201 | 202 | 4. Conveying Verbatim Copies. 203 | 204 | You may convey verbatim copies of the Program's source code as you 205 | receive it, in any medium, provided that you conspicuously and 206 | appropriately publish on each copy an appropriate copyright notice; 207 | keep intact all notices stating that this License and any 208 | non-permissive terms added in accord with section 7 apply to the code; 209 | keep intact all notices of the absence of any warranty; and give all 210 | recipients a copy of this License along with the Program. 211 | 212 | You may charge any price or no price for each copy that you convey, 213 | and you may offer support or warranty protection for a fee. 214 | 215 | 5. Conveying Modified Source Versions. 216 | 217 | You may convey a work based on the Program, or the modifications to 218 | produce it from the Program, in the form of source code under the 219 | terms of section 4, provided that you also meet all of these conditions: 220 | 221 | a) The work must carry prominent notices stating that you modified 222 | it, and giving a relevant date. 223 | 224 | b) The work must carry prominent notices stating that it is 225 | released under this License and any conditions added under section 226 | 7. This requirement modifies the requirement in section 4 to 227 | "keep intact all notices". 228 | 229 | c) You must license the entire work, as a whole, under this 230 | License to anyone who comes into possession of a copy. This 231 | License will therefore apply, along with any applicable section 7 232 | additional terms, to the whole of the work, and all its parts, 233 | regardless of how they are packaged. This License gives no 234 | permission to license the work in any other way, but it does not 235 | invalidate such permission if you have separately received it. 236 | 237 | d) If the work has interactive user interfaces, each must display 238 | Appropriate Legal Notices; however, if the Program has interactive 239 | interfaces that do not display Appropriate Legal Notices, your 240 | work need not make them do so. 241 | 242 | A compilation of a covered work with other separate and independent 243 | works, which are not by their nature extensions of the covered work, 244 | and which are not combined with it such as to form a larger program, 245 | in or on a volume of a storage or distribution medium, is called an 246 | "aggregate" if the compilation and its resulting copyright are not 247 | used to limit the access or legal rights of the compilation's users 248 | beyond what the individual works permit. Inclusion of a covered work 249 | in an aggregate does not cause this License to apply to the other 250 | parts of the aggregate. 251 | 252 | 6. Conveying Non-Source Forms. 253 | 254 | You may convey a covered work in object code form under the terms 255 | of sections 4 and 5, provided that you also convey the 256 | machine-readable Corresponding Source under the terms of this License, 257 | in one of these ways: 258 | 259 | a) Convey the object code in, or embodied in, a physical product 260 | (including a physical distribution medium), accompanied by the 261 | Corresponding Source fixed on a durable physical medium 262 | customarily used for software interchange. 263 | 264 | b) Convey the object code in, or embodied in, a physical product 265 | (including a physical distribution medium), accompanied by a 266 | written offer, valid for at least three years and valid for as 267 | long as you offer spare parts or customer support for that product 268 | model, to give anyone who possesses the object code either (1) a 269 | copy of the Corresponding Source for all the software in the 270 | product that is covered by this License, on a durable physical 271 | medium customarily used for software interchange, for a price no 272 | more than your reasonable cost of physically performing this 273 | conveying of source, or (2) access to copy the 274 | Corresponding Source from a network server at no charge. 275 | 276 | c) Convey individual copies of the object code with a copy of the 277 | written offer to provide the Corresponding Source. This 278 | alternative is allowed only occasionally and noncommercially, and 279 | only if you received the object code with such an offer, in accord 280 | with subsection 6b. 281 | 282 | d) Convey the object code by offering access from a designated 283 | place (gratis or for a charge), and offer equivalent access to the 284 | Corresponding Source in the same way through the same place at no 285 | further charge. You need not require recipients to copy the 286 | Corresponding Source along with the object code. If the place to 287 | copy the object code is a network server, the Corresponding Source 288 | may be on a different server (operated by you or a third party) 289 | that supports equivalent copying facilities, provided you maintain 290 | clear directions next to the object code saying where to find the 291 | Corresponding Source. Regardless of what server hosts the 292 | Corresponding Source, you remain obligated to ensure that it is 293 | available for as long as needed to satisfy these requirements. 294 | 295 | e) Convey the object code using peer-to-peer transmission, provided 296 | you inform other peers where the object code and Corresponding 297 | Source of the work are being offered to the general public at no 298 | charge under subsection 6d. 299 | 300 | A separable portion of the object code, whose source code is excluded 301 | from the Corresponding Source as a System Library, need not be 302 | included in conveying the object code work. 303 | 304 | A "User Product" is either (1) a "consumer product", which means any 305 | tangible personal property which is normally used for personal, family, 306 | or household purposes, or (2) anything designed or sold for incorporation 307 | into a dwelling. In determining whether a product is a consumer product, 308 | doubtful cases shall be resolved in favor of coverage. For a particular 309 | product received by a particular user, "normally used" refers to a 310 | typical or common use of that class of product, regardless of the status 311 | of the particular user or of the way in which the particular user 312 | actually uses, or expects or is expected to use, the product. A product 313 | is a consumer product regardless of whether the product has substantial 314 | commercial, industrial or non-consumer uses, unless such uses represent 315 | the only significant mode of use of the product. 316 | 317 | "Installation Information" for a User Product means any methods, 318 | procedures, authorization keys, or other information required to install 319 | and execute modified versions of a covered work in that User Product from 320 | a modified version of its Corresponding Source. The information must 321 | suffice to ensure that the continued functioning of the modified object 322 | code is in no case prevented or interfered with solely because 323 | modification has been made. 324 | 325 | If you convey an object code work under this section in, or with, or 326 | specifically for use in, a User Product, and the conveying occurs as 327 | part of a transaction in which the right of possession and use of the 328 | User Product is transferred to the recipient in perpetuity or for a 329 | fixed term (regardless of how the transaction is characterized), the 330 | Corresponding Source conveyed under this section must be accompanied 331 | by the Installation Information. But this requirement does not apply 332 | if neither you nor any third party retains the ability to install 333 | modified object code on the User Product (for example, the work has 334 | been installed in ROM). 335 | 336 | The requirement to provide Installation Information does not include a 337 | requirement to continue to provide support service, warranty, or updates 338 | for a work that has been modified or installed by the recipient, or for 339 | the User Product in which it has been modified or installed. Access to a 340 | network may be denied when the modification itself materially and 341 | adversely affects the operation of the network or violates the rules and 342 | protocols for communication across the network. 343 | 344 | Corresponding Source conveyed, and Installation Information provided, 345 | in accord with this section must be in a format that is publicly 346 | documented (and with an implementation available to the public in 347 | source code form), and must require no special password or key for 348 | unpacking, reading or copying. 349 | 350 | 7. Additional Terms. 351 | 352 | "Additional permissions" are terms that supplement the terms of this 353 | License by making exceptions from one or more of its conditions. 354 | Additional permissions that are applicable to the entire Program shall 355 | be treated as though they were included in this License, to the extent 356 | that they are valid under applicable law. If additional permissions 357 | apply only to part of the Program, that part may be used separately 358 | under those permissions, but the entire Program remains governed by 359 | this License without regard to the additional permissions. 360 | 361 | When you convey a copy of a covered work, you may at your option 362 | remove any additional permissions from that copy, or from any part of 363 | it. (Additional permissions may be written to require their own 364 | removal in certain cases when you modify the work.) You may place 365 | additional permissions on material, added by you to a covered work, 366 | for which you have or can give appropriate copyright permission. 367 | 368 | Notwithstanding any other provision of this License, for material you 369 | add to a covered work, you may (if authorized by the copyright holders of 370 | that material) supplement the terms of this License with terms: 371 | 372 | a) Disclaiming warranty or limiting liability differently from the 373 | terms of sections 15 and 16 of this License; or 374 | 375 | b) Requiring preservation of specified reasonable legal notices or 376 | author attributions in that material or in the Appropriate Legal 377 | Notices displayed by works containing it; or 378 | 379 | c) Prohibiting misrepresentation of the origin of that material, or 380 | requiring that modified versions of such material be marked in 381 | reasonable ways as different from the original version; or 382 | 383 | d) Limiting the use for publicity purposes of names of licensors or 384 | authors of the material; or 385 | 386 | e) Declining to grant rights under trademark law for use of some 387 | trade names, trademarks, or service marks; or 388 | 389 | f) Requiring indemnification of licensors and authors of that 390 | material by anyone who conveys the material (or modified versions of 391 | it) with contractual assumptions of liability to the recipient, for 392 | any liability that these contractual assumptions directly impose on 393 | those licensors and authors. 394 | 395 | All other non-permissive additional terms are considered "further 396 | restrictions" within the meaning of section 10. If the Program as you 397 | received it, or any part of it, contains a notice stating that it is 398 | governed by this License along with a term that is a further 399 | restriction, you may remove that term. If a license document contains 400 | a further restriction but permits relicensing or conveying under this 401 | License, you may add to a covered work material governed by the terms 402 | of that license document, provided that the further restriction does 403 | not survive such relicensing or conveying. 404 | 405 | If you add terms to a covered work in accord with this section, you 406 | must place, in the relevant source files, a statement of the 407 | additional terms that apply to those files, or a notice indicating 408 | where to find the applicable terms. 409 | 410 | Additional terms, permissive or non-permissive, may be stated in the 411 | form of a separately written license, or stated as exceptions; 412 | the above requirements apply either way. 413 | 414 | 8. Termination. 415 | 416 | You may not propagate or modify a covered work except as expressly 417 | provided under this License. Any attempt otherwise to propagate or 418 | modify it is void, and will automatically terminate your rights under 419 | this License (including any patent licenses granted under the third 420 | paragraph of section 11). 421 | 422 | However, if you cease all violation of this License, then your 423 | license from a particular copyright holder is reinstated (a) 424 | provisionally, unless and until the copyright holder explicitly and 425 | finally terminates your license, and (b) permanently, if the copyright 426 | holder fails to notify you of the violation by some reasonable means 427 | prior to 60 days after the cessation. 428 | 429 | Moreover, your license from a particular copyright holder is 430 | reinstated permanently if the copyright holder notifies you of the 431 | violation by some reasonable means, this is the first time you have 432 | received notice of violation of this License (for any work) from that 433 | copyright holder, and you cure the violation prior to 30 days after 434 | your receipt of the notice. 435 | 436 | Termination of your rights under this section does not terminate the 437 | licenses of parties who have received copies or rights from you under 438 | this License. If your rights have been terminated and not permanently 439 | reinstated, you do not qualify to receive new licenses for the same 440 | material under section 10. 441 | 442 | 9. Acceptance Not Required for Having Copies. 443 | 444 | You are not required to accept this License in order to receive or 445 | run a copy of the Program. Ancillary propagation of a covered work 446 | occurring solely as a consequence of using peer-to-peer transmission 447 | to receive a copy likewise does not require acceptance. However, 448 | nothing other than this License grants you permission to propagate or 449 | modify any covered work. These actions infringe copyright if you do 450 | not accept this License. Therefore, by modifying or propagating a 451 | covered work, you indicate your acceptance of this License to do so. 452 | 453 | 10. Automatic Licensing of Downstream Recipients. 454 | 455 | Each time you convey a covered work, the recipient automatically 456 | receives a license from the original licensors, to run, modify and 457 | propagate that work, subject to this License. You are not responsible 458 | for enforcing compliance by third parties with this License. 459 | 460 | An "entity transaction" is a transaction transferring control of an 461 | organization, or substantially all assets of one, or subdividing an 462 | organization, or merging organizations. If propagation of a covered 463 | work results from an entity transaction, each party to that 464 | transaction who receives a copy of the work also receives whatever 465 | licenses to the work the party's predecessor in interest had or could 466 | give under the previous paragraph, plus a right to possession of the 467 | Corresponding Source of the work from the predecessor in interest, if 468 | the predecessor has it or can get it with reasonable efforts. 469 | 470 | You may not impose any further restrictions on the exercise of the 471 | rights granted or affirmed under this License. For example, you may 472 | not impose a license fee, royalty, or other charge for exercise of 473 | rights granted under this License, and you may not initiate litigation 474 | (including a cross-claim or counterclaim in a lawsuit) alleging that 475 | any patent claim is infringed by making, using, selling, offering for 476 | sale, or importing the Program or any portion of it. 477 | 478 | 11. Patents. 479 | 480 | A "contributor" is a copyright holder who authorizes use under this 481 | License of the Program or a work on which the Program is based. The 482 | work thus licensed is called the contributor's "contributor version". 483 | 484 | A contributor's "essential patent claims" are all patent claims 485 | owned or controlled by the contributor, whether already acquired or 486 | hereafter acquired, that would be infringed by some manner, permitted 487 | by this License, of making, using, or selling its contributor version, 488 | but do not include claims that would be infringed only as a 489 | consequence of further modification of the contributor version. For 490 | purposes of this definition, "control" includes the right to grant 491 | patent sublicenses in a manner consistent with the requirements of 492 | this License. 493 | 494 | Each contributor grants you a non-exclusive, worldwide, royalty-free 495 | patent license under the contributor's essential patent claims, to 496 | make, use, sell, offer for sale, import and otherwise run, modify and 497 | propagate the contents of its contributor version. 498 | 499 | In the following three paragraphs, a "patent license" is any express 500 | agreement or commitment, however denominated, not to enforce a patent 501 | (such as an express permission to practice a patent or covenant not to 502 | sue for patent infringement). To "grant" such a patent license to a 503 | party means to make such an agreement or commitment not to enforce a 504 | patent against the party. 505 | 506 | If you convey a covered work, knowingly relying on a patent license, 507 | and the Corresponding Source of the work is not available for anyone 508 | to copy, free of charge and under the terms of this License, through a 509 | publicly available network server or other readily accessible means, 510 | then you must either (1) cause the Corresponding Source to be so 511 | available, or (2) arrange to deprive yourself of the benefit of the 512 | patent license for this particular work, or (3) arrange, in a manner 513 | consistent with the requirements of this License, to extend the patent 514 | license to downstream recipients. "Knowingly relying" means you have 515 | actual knowledge that, but for the patent license, your conveying the 516 | covered work in a country, or your recipient's use of the covered work 517 | in a country, would infringe one or more identifiable patents in that 518 | country that you have reason to believe are valid. 519 | 520 | If, pursuant to or in connection with a single transaction or 521 | arrangement, you convey, or propagate by procuring conveyance of, a 522 | covered work, and grant a patent license to some of the parties 523 | receiving the covered work authorizing them to use, propagate, modify 524 | or convey a specific copy of the covered work, then the patent license 525 | you grant is automatically extended to all recipients of the covered 526 | work and works based on it. 527 | 528 | A patent license is "discriminatory" if it does not include within 529 | the scope of its coverage, prohibits the exercise of, or is 530 | conditioned on the non-exercise of one or more of the rights that are 531 | specifically granted under this License. You may not convey a covered 532 | work if you are a party to an arrangement with a third party that is 533 | in the business of distributing software, under which you make payment 534 | to the third party based on the extent of your activity of conveying 535 | the work, and under which the third party grants, to any of the 536 | parties who would receive the covered work from you, a discriminatory 537 | patent license (a) in connection with copies of the covered work 538 | conveyed by you (or copies made from those copies), or (b) primarily 539 | for and in connection with specific products or compilations that 540 | contain the covered work, unless you entered into that arrangement, 541 | or that patent license was granted, prior to 28 March 2007. 542 | 543 | Nothing in this License shall be construed as excluding or limiting 544 | any implied license or other defenses to infringement that may 545 | otherwise be available to you under applicable patent law. 546 | 547 | 12. No Surrender of Others' Freedom. 548 | 549 | If conditions are imposed on you (whether by court order, agreement or 550 | otherwise) that contradict the conditions of this License, they do not 551 | excuse you from the conditions of this License. If you cannot convey a 552 | covered work so as to satisfy simultaneously your obligations under this 553 | License and any other pertinent obligations, then as a consequence you may 554 | not convey it at all. For example, if you agree to terms that obligate you 555 | to collect a royalty for further conveying from those to whom you convey 556 | the Program, the only way you could satisfy both those terms and this 557 | License would be to refrain entirely from conveying the Program. 558 | 559 | 13. Remote Network Interaction; Use with the GNU General Public License. 560 | 561 | Notwithstanding any other provision of this License, if you modify the 562 | Program, your modified version must prominently offer all users 563 | interacting with it remotely through a computer network (if your version 564 | supports such interaction) an opportunity to receive the Corresponding 565 | Source of your version by providing access to the Corresponding Source 566 | from a network server at no charge, through some standard or customary 567 | means of facilitating copying of software. This Corresponding Source 568 | shall include the Corresponding Source for any work covered by version 3 569 | of the GNU General Public License that is incorporated pursuant to the 570 | following paragraph. 571 | 572 | Notwithstanding any other provision of this License, you have 573 | permission to link or combine any covered work with a work licensed 574 | under version 3 of the GNU General Public License into a single 575 | combined work, and to convey the resulting work. The terms of this 576 | License will continue to apply to the part which is the covered work, 577 | but the work with which it is combined will remain governed by version 578 | 3 of the GNU General Public License. 579 | 580 | 14. Revised Versions of this License. 581 | 582 | The Free Software Foundation may publish revised and/or new versions of 583 | the GNU Affero General Public License from time to time. Such new versions 584 | will be similar in spirit to the present version, but may differ in detail to 585 | address new problems or concerns. 586 | 587 | Each version is given a distinguishing version number. If the 588 | Program specifies that a certain numbered version of the GNU Affero General 589 | Public License "or any later version" applies to it, you have the 590 | option of following the terms and conditions either of that numbered 591 | version or of any later version published by the Free Software 592 | Foundation. If the Program does not specify a version number of the 593 | GNU Affero General Public License, you may choose any version ever published 594 | by the Free Software Foundation. 595 | 596 | If the Program specifies that a proxy can decide which future 597 | versions of the GNU Affero General Public License can be used, that proxy's 598 | public statement of acceptance of a version permanently authorizes you 599 | to choose that version for the Program. 600 | 601 | Later license versions may give you additional or different 602 | permissions. However, no additional obligations are imposed on any 603 | author or copyright holder as a result of your choosing to follow a 604 | later version. 605 | 606 | 15. Disclaimer of Warranty. 607 | 608 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 609 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 610 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 611 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 612 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 613 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 614 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 615 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 616 | 617 | 16. Limitation of Liability. 618 | 619 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 620 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 621 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 622 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 623 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 624 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 625 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 626 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 627 | SUCH DAMAGES. 628 | 629 | 17. Interpretation of Sections 15 and 16. 630 | 631 | If the disclaimer of warranty and limitation of liability provided 632 | above cannot be given local legal effect according to their terms, 633 | reviewing courts shall apply local law that most closely approximates 634 | an absolute waiver of all civil liability in connection with the 635 | Program, unless a warranty or assumption of liability accompanies a 636 | copy of the Program in return for a fee. 637 | 638 | END OF TERMS AND CONDITIONS 639 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # prefix-server 2 | [![Build Status](https://travis-ci.org/zazuko/prefix-server.svg?branch=master)](https://travis-ci.org/zazuko/prefix-server) 3 | 4 | > RDF prefix / namespaces resolution 5 | 6 | ## Build Setup 7 | 8 | ```bash 9 | # install dependencies 10 | $ npm ci 11 | $ npm run build-data 12 | 13 | # serve with hot reload at localhost:3000 14 | $ npm run dev 15 | 16 | # build for production and launch server 17 | $ npm run build 18 | $ npm run start 19 | ``` 20 | 21 | ## Tests 22 | 23 | ```bash 24 | # run the dev server 25 | $ npm run dev 26 | 27 | # run the tests in a window 28 | $ npm run e2e:open 29 | 30 | ## OR 31 | 32 | # run the tests headless 33 | $ npm run e2e:test 34 | ``` 35 | 36 | ## Building the resources used by the API 37 | 38 | The resources can be rebuilt using `npm run build-data`. 39 | 40 | They are not built by the hot-reload dev server because building the resources 41 | takes time. 42 | -------------------------------------------------------------------------------- /api/datafiles/.gitignore: -------------------------------------------------------------------------------- 1 | !.gitignore 2 | -------------------------------------------------------------------------------- /api/etag-middleware.js: -------------------------------------------------------------------------------- 1 | const express = require('express') 2 | const preconditions = require('express-preconditions') 3 | const hash = require('string-hash') 4 | 5 | const app = express() 6 | 7 | app.use(etag(process.env.APP_VERSION || '')) 8 | app.use(preconditions()) 9 | 10 | function etag (version) { 11 | return (req, res, next) => { 12 | const resource = `${version}:${req.originalUrl}` 13 | res.setHeader('ETag', hash(resource).toString(16)) 14 | next() 15 | } 16 | } 17 | 18 | module.exports = app 19 | -------------------------------------------------------------------------------- /api/index.js: -------------------------------------------------------------------------------- 1 | const fs = require('fs') 2 | const path = require('path') 3 | const zlib = require('zlib') 4 | const express = require('express') 5 | const Fuse = require('fuse.js') 6 | const { asyncMiddleware } = require('middleware-async') 7 | 8 | const { cachedShrink, cachedExpand } = require('./utils') 9 | 10 | const loadDataFile = file => 11 | JSON.parse(zlib.gunzipSync(fs.readFileSync(path.join(__dirname, `./datafiles/${file}.json.gz`)))) 12 | 13 | const app = express() 14 | const router = express.Router() 15 | 16 | const searchArray = loadDataFile('searchArray') 17 | const searchArrayByPrefix = loadDataFile('searchArrayByPrefix') 18 | const prefixEndpointData = loadDataFile('prefixEndpointData') 19 | const prefixMetadata = loadDataFile('prefixMetadata') 20 | const summary = loadDataFile('summary') 21 | const fuseOptions = loadDataFile('fuseOptions') 22 | const prefixComplete = loadDataFile('prefixComplete') 23 | 24 | const fuse = new Fuse(searchArray, fuseOptions) 25 | Object.keys(searchArrayByPrefix).forEach((key) => { 26 | searchArrayByPrefix[key] = new Fuse(searchArrayByPrefix[key], fuseOptions) 27 | }) 28 | 29 | module.exports = { path: '/api/v1', handler: app } 30 | 31 | router.get('/search', (req, res) => { 32 | const query = (req.query.q || '').replace(/---hash---/g, '#').trim() 33 | 34 | if (!query) { 35 | res.json([]) 36 | return 37 | } 38 | 39 | // detect queries like this: `skos:`, `skos:foo` 40 | // do not detect queries containing a URL or spaces 41 | if (query.split(' ').length <= 1 && query.split('.').length <= 3 && !query.includes('://')) { 42 | const prefix = query.split(':')[0] 43 | // scope the search to only this prefix 44 | if (searchArrayByPrefix[prefix]) { 45 | res.json(searchArrayByPrefix[prefix].search(query).slice(0, 10).map(({ item }) => item)) 46 | return 47 | } 48 | } 49 | 50 | res.json(fuse.search(query).slice(0, 10).map(({ item }) => item)) 51 | }) 52 | 53 | router.get('/suggest', (req, res) => { 54 | const query = (req.query.q || '').replace(/---hash---/g, '#').trim() 55 | 56 | if (!query) { 57 | res.json([]) 58 | return 59 | } 60 | 61 | let results 62 | 63 | // detect queries like this: `skos:`, `skos:foo` 64 | // do not detect queries containing a URL or spaces 65 | if (query.split(' ').length <= 1 && query.split('.').length <= 3 && !query.includes('://')) { 66 | const prefix = query.split(':')[0] 67 | // scope the search to only this prefix 68 | if (searchArrayByPrefix[prefix]) { 69 | results = searchArrayByPrefix[prefix].search(query).slice(0, 10).map(({ item }) => item) 70 | } 71 | } 72 | if (!results) { 73 | results = fuse.search(query).slice(0, 10).map(({ item }) => item) 74 | } 75 | 76 | res.json(results.map(item => item.prefixed)) 77 | }) 78 | 79 | router.get('/prefix', (req, res) => { 80 | const query = (req.query.q || '').trim() 81 | const prefix = query.split(':')[0] 82 | 83 | if (!prefix || !prefixEndpointData[prefix]) { 84 | res.status(404).json([]) 85 | return 86 | } 87 | res.json({ 88 | data: prefixEndpointData[prefix], 89 | metadata: prefixMetadata[prefix] 90 | }) 91 | }) 92 | 93 | router.get('/prefixes', (req, res) => { 94 | res.json(Object.fromEntries(Object.entries(prefixMetadata).map(([prefix, value]) => [prefix, value.namespace]))) 95 | }) 96 | 97 | router.get('/summary', (req, res) => { 98 | res.json(summary) 99 | }) 100 | 101 | router.get('/shrink', asyncMiddleware(async (req, res) => { 102 | let iri = req.query.q 103 | 104 | if (iri) { 105 | // detect URI encoded `://` 106 | if (iri.includes('%3A%2F%2F')) { 107 | iri = decodeURIComponent(iri) 108 | } 109 | const attempt = await cachedShrink({ value: iri }) 110 | if (attempt !== iri) { 111 | return res.json({ 112 | success: true, 113 | value: attempt 114 | }) 115 | } 116 | return res.status(404).json({ 117 | success: false 118 | }) 119 | } 120 | 121 | res.status(400).json({ help: '/api/v1/shrink?q=…' }) 122 | })) 123 | 124 | router.get('/expand', asyncMiddleware(async (req, res) => { 125 | const prefixed = req.query.q 126 | 127 | if (prefixed) { 128 | const attempt = await cachedExpand(prefixed) 129 | if (attempt !== prefixed) { 130 | return res.json({ 131 | success: true, 132 | value: attempt 133 | }) 134 | } 135 | return res.status(404).json({ 136 | success: false 137 | }) 138 | } 139 | 140 | res.status(400).json({ help: '/api/v1/expand?q=…' }) 141 | })) 142 | 143 | router.get('/autocomplete', asyncMiddleware(async (req, res) => { 144 | const { prefixes } = await import('@zazuko/vocabularies') 145 | 146 | const matchCase = req.query.case === 'true' 147 | const expand = req.query.expand === 'true' 148 | const query = req.query.q 149 | const type = req.query.type 150 | 151 | if (!('q' in req.query)) { 152 | return res.status(400).json({ help: '/api/v1/autocomplete?q=…[&type=…][&case=true][&expand]' }) 153 | } 154 | if (!query.includes(':')) { 155 | const potentialPrefixes = Object.keys(prefixComplete) 156 | .filter(prefix => prefix.startsWith(query)) 157 | 158 | if (expand) { 159 | return res.json(potentialPrefixes.map(item => prefixes[item])) 160 | } 161 | return res.json(potentialPrefixes.map(prefix => `${prefix}:`)) 162 | } 163 | const [searchPrefix, searchTerm] = query.split(':') 164 | const vocab = prefixComplete[matchCase ? searchPrefix : searchPrefix.toLowerCase()] 165 | if (!vocab) { 166 | return res.status(404).json({ 167 | success: false 168 | }) 169 | } 170 | 171 | if (type && !type.includes(':')) { 172 | return res.json([]) 173 | } 174 | const results = Object.entries(vocab) 175 | .reduce((acc, [term, types]) => { 176 | if (!(matchCase ? term.startsWith(searchTerm) : term.toLowerCase().startsWith(searchTerm.toLowerCase()))) { 177 | return acc 178 | } 179 | if (type) { 180 | if (types.find(t => matchCase ? t === type : t.toLowerCase() === type.toLowerCase())) { 181 | acc.push(`${searchPrefix}:${term}`) 182 | } 183 | } 184 | else { 185 | acc.push(`${searchPrefix}:${term}`) 186 | } 187 | return acc 188 | }, []) 189 | 190 | if (expand) { 191 | return res.json(await Promise.all(results.map(item => cachedExpand(item)))) 192 | } 193 | 194 | res.json(results) 195 | })) 196 | 197 | router.get('/health', (req, res) => { 198 | res.json('ok') 199 | }) 200 | 201 | app.use(router) 202 | -------------------------------------------------------------------------------- /api/utils.js: -------------------------------------------------------------------------------- 1 | const _ = require('lodash') 2 | const debug = require('debug')('prefix-server') 3 | const { namedNode } = require('@rdfjs/data-model') 4 | 5 | const labelPredicates = [ 6 | 'http://www.w3.org/2000/01/rdf-schema#label', 7 | 'http://www.w3.org/2004/02/skos/core#prefLabel' 8 | ] 9 | 10 | module.exports = { 11 | cachedShrink, 12 | cachedExpand, 13 | prepareData 14 | } 15 | 16 | const shrunkCache = {} 17 | const expandedCache = {} 18 | const fuseOptions = { 19 | caseSensitive: true, 20 | shouldSort: true, 21 | treshold: 0.2, 22 | distance: 40, 23 | minMatchCharLength: 2, 24 | maxPatternLength: 40, 25 | keys: [{ 26 | name: 'prefixed', 27 | weight: 6 / 15 28 | }, { 29 | name: 'label', 30 | weight: 4 / 15 31 | }, { 32 | name: 'parts.object.value', 33 | weight: 2 / 15 34 | }, { 35 | name: 'iri.value', 36 | weight: 3 / 15 37 | }] 38 | } 39 | 40 | async function cachedShrink (term) { 41 | const { shrink } = await import('@zazuko/vocabularies') 42 | 43 | const cached = shrunkCache[term.value] 44 | if (cached) { 45 | return cached 46 | } 47 | const shrunk = shrink(term.value) || term.value 48 | shrunkCache[term.value] = shrunk 49 | return shrunk 50 | } 51 | 52 | async function cachedExpand (prefixed) { 53 | const { expand } = await import('@zazuko/vocabularies') 54 | 55 | const cached = expandedCache[prefixed] 56 | if (cached) { 57 | return cached 58 | } 59 | let expanded = prefixed 60 | try { 61 | expanded = expand(prefixed) || prefixed 62 | expandedCache[prefixed] = expanded 63 | } 64 | catch (err) { 65 | // 66 | } 67 | return expanded 68 | } 69 | 70 | function enrichPrefixSpecificData (searchArrayByPrefix, prefixEndpointData) { 71 | for (const prefix in searchArrayByPrefix) { 72 | prefixEndpointData[prefix] = { 73 | otherTypes: [] 74 | } 75 | for (const term of searchArrayByPrefix[prefix]) { 76 | if (!term.prefixed.startsWith(prefix)) { 77 | // for instance if the ontology `foo:` contains triples indicating its author: 78 | // rdf:type foaf:Person . 79 | // we want to filter it out. 80 | continue 81 | } 82 | const termToAdd = { 83 | itemText: term.itemText, 84 | iri: term.iri, 85 | label: term.label, 86 | prefixed: term.prefixed 87 | } 88 | 89 | // some terms have several types 90 | const typeParts = term.parts.filter(({ predicate }) => predicate === 'rdf:type') 91 | 92 | for (const typePart of typeParts) { 93 | const type = typePart.object 94 | 95 | if (type.startsWith('http://') || type.startsWith('https://')) { 96 | prefixEndpointData[prefix].otherTypes.push(type) 97 | continue 98 | } 99 | 100 | if (!prefixEndpointData[prefix][type]) { 101 | prefixEndpointData[prefix][type] = [] 102 | } 103 | prefixEndpointData[prefix][type].push(termToAdd) 104 | } 105 | } 106 | Object.keys(prefixEndpointData[prefix]).forEach((term) => { 107 | prefixEndpointData[prefix][term] = _.sortBy(prefixEndpointData[prefix][term], 'prefixed') 108 | }) 109 | } 110 | } 111 | 112 | async function createSearchArray (datasets, prefixMetadata) { 113 | const { prefixes } = await import('@zazuko/vocabularies') 114 | 115 | let loadedPrefixesCount = 0 116 | let loadedTermsCount = 0 117 | const searchArrayByPrefix = {} 118 | const prefixEndpointData = {} 119 | const summary = [] 120 | 121 | // list all quads from all datasets 122 | const quads = Object.entries(datasets) 123 | .reduce((acc, [prefix, dataset]) => { 124 | // some prefix datasets define triples that should not be part of the prefix, for instance we should only 125 | // care about triples from `frbr:` for which the subject IRI actually starts with `http://purl.org/vocab/frbr/core#`, 126 | // which unfortunately isn't always the case: 127 | // https://github.com/zazuko/rdf-vocabularies/blob/3027a5c5aedf0bf0439d68d779856ace9c57b3f7/ontologies/frbr.nq#L348-L350 128 | const filtered = [...dataset.filter(({ subject }) => subject.value.startsWith(prefixes[prefix]))] 129 | 130 | if (filtered.length > 0) { 131 | loadedPrefixesCount += 1 132 | loadedTermsCount += filtered.length 133 | } 134 | 135 | summary.push({ 136 | prefix, 137 | terms: filtered.length 138 | }) 139 | return acc.concat(filtered) 140 | }, []) 141 | 142 | const obj = [] 143 | for (const quad of quads) { 144 | let { predicate, object } = quad 145 | let predicateIRI, objectIRI 146 | 147 | if (predicate.termType === 'NamedNode') { 148 | predicateIRI = predicate.value 149 | predicate = await cachedShrink(predicate) 150 | } 151 | if (object.termType === 'NamedNode') { 152 | objectIRI = object.value 153 | object = await cachedShrink(object) 154 | } 155 | const part = { predicate, predicateIRI, object, objectIRI, quad } 156 | 157 | const index = obj.findIndex(x => x.iri.equals(quad.subject)) 158 | if (index !== -1) { 159 | obj[index].parts.push(part) 160 | } 161 | else { 162 | const termToAdd = { 163 | iri: quad.subject, 164 | prefixed: await cachedShrink(quad.subject), 165 | graph: quad.graph, 166 | parts: [part] 167 | } 168 | const [prefixedSplitA, prefixedSplitB] = termToAdd.prefixed.split(':') 169 | // see https://github.com/zazuko/prefix-server/issues/26 170 | const iriSplitA = prefixedSplitB ? termToAdd.iri.value.split(prefixedSplitB)[0] : termToAdd.iri.value 171 | const ontologyTitle = prefixMetadata[prefixedSplitA].title || '' 172 | Object.assign(termToAdd, { 173 | prefixedSplitA, 174 | prefixedSplitB, 175 | iriSplitA, 176 | iriSplitB: prefixedSplitB, 177 | ontologyTitle 178 | }) 179 | 180 | obj.push(termToAdd) 181 | } 182 | } 183 | 184 | const searchArray = obj.map((term) => { 185 | const labels = term.parts.reduce((labels, part) => { 186 | if (labelPredicates.includes(part.predicateIRI)) { 187 | const language = part.object.language 188 | if (typeof language === 'string') { 189 | labels[language] = part.object.value 190 | } 191 | else { 192 | if (!labels['no language']) { 193 | labels['no language'] = [] 194 | } 195 | labels['no language'].push(part.object.value) 196 | } 197 | } 198 | return labels 199 | }, {}) 200 | 201 | // choose the best label to display 202 | if (labels.en) { 203 | // 1st priority is English 204 | term.label = labels.en 205 | } 206 | else if (labels['']) { 207 | // sometimes the English label has an empty language 208 | term.label = labels[''] 209 | } 210 | else if (labels['no language']) { 211 | // last resort, a label with no specified language 212 | term.label = labels['no language'].join('\n') 213 | } 214 | 215 | term.itemText = term.prefixed 216 | if (term.label) { 217 | // ― 218 | term.itemText += ` (${term.label})` 219 | } 220 | 221 | // create the prefix-specific search array 222 | const prefix = term.prefixedSplitA 223 | if (!searchArrayByPrefix[prefix]) { 224 | searchArrayByPrefix[prefix] = [] 225 | } 226 | searchArrayByPrefix[prefix].push(term) 227 | 228 | return term 229 | }) 230 | 231 | return { 232 | summary: _.sortBy(summary, 'prefix'), 233 | searchArray, 234 | searchArrayByPrefix, 235 | prefixEndpointData, 236 | stats: { 237 | loadedPrefixesCount, 238 | loadedTermsCount 239 | } 240 | } 241 | } 242 | 243 | async function findPrefixMetadata (datasets, index) { 244 | const { prefixes } = await import('@zazuko/vocabularies') 245 | 246 | const output = {} 247 | Object.entries(datasets).forEach(([prefix, dataset]) => { 248 | const namespace = prefixes[prefix] 249 | const title = [...index.match(namedNode(`https://prefix.zazuko.com/${prefix}:`), namedNode('http://purl.org/dc/terms/title'))] 250 | const description = [...index.match(namedNode(`https://prefix.zazuko.com/${prefix}:`), namedNode('http://purl.org/dc/terms/description'))] 251 | 252 | output[prefix] = { 253 | namespace, 254 | title: (title.length && title[0].object.value) || '', 255 | description: (description.length && description[0].object.value) || '' 256 | } 257 | }) 258 | return output 259 | } 260 | 261 | function preparePrefixComplete (searchArrayByPrefix) { 262 | const prefixComplete = {} 263 | for (const prefix in searchArrayByPrefix) { 264 | const terms = searchArrayByPrefix[prefix] 265 | const obj = {} 266 | prefixComplete[prefix] = obj 267 | for (const term of terms) { 268 | const types = term.parts.reduce((acc, { predicate, object, objectIRI }) => { 269 | if (predicate === 'rdf:type') { 270 | acc.push(object) 271 | } 272 | return acc 273 | }, []) 274 | obj[term.prefixedSplitB] = types 275 | } 276 | } 277 | return prefixComplete 278 | } 279 | 280 | async function prepareData () { 281 | const now = Date.now() 282 | 283 | const { vocabularies } = await import('@zazuko/vocabularies') 284 | const datasets = await vocabularies() 285 | const index = await (await import('@zazuko/vocabularies/meta')).default() 286 | const prefixMetadata = await findPrefixMetadata(datasets, index) 287 | 288 | const { 289 | summary, 290 | searchArray, 291 | searchArrayByPrefix, 292 | prefixEndpointData, 293 | stats 294 | } = await createSearchArray(datasets, prefixMetadata) 295 | enrichPrefixSpecificData(searchArrayByPrefix, prefixEndpointData) 296 | 297 | const prefixComplete = preparePrefixComplete(searchArrayByPrefix) 298 | 299 | debug(`API data generated in ${Date.now() - now}ms, loaded ${stats.loadedPrefixesCount} prefixes for a total of ${stats.loadedTermsCount} triples`) 300 | 301 | return { 302 | searchArray, 303 | searchArrayByPrefix, 304 | prefixMetadata, 305 | prefixEndpointData, 306 | summary, 307 | fuseOptions, 308 | prefixComplete 309 | } 310 | } 311 | -------------------------------------------------------------------------------- /assets/zazuko/404-layout.scss: -------------------------------------------------------------------------------- 1 | .layout-404 { 2 | width: 100vw; 3 | height: 100vh; 4 | 5 | display: flex; 6 | align-items: center; 7 | justify-content: center; 8 | text-align: center; 9 | 10 | background: $color-primary-h; 11 | background-image: linear-gradient(to bottom right, $color-primary, $color-primary-h); 12 | 13 | h1 { 14 | font-size: $fs-header; 15 | line-height: $fs-header + 40; 16 | font-family: $font-header; 17 | font-weight: 700; 18 | } 19 | 20 | h2 { 21 | font-size: $fs-title; 22 | line-height: $fs-title; 23 | padding-bottom: 20px; 24 | text-transform: uppercase; 25 | } 26 | 27 | a { 28 | color: black; 29 | text-decoration: none; 30 | } 31 | } -------------------------------------------------------------------------------- /assets/zazuko/footer.scss: -------------------------------------------------------------------------------- 1 | footer { 2 | background: $color-primary; 3 | border-top: solid 1px rgba(0, 0, 0, .2); 4 | 5 | 6 | .footer-container { 7 | @include container; 8 | 9 | line-height: 50px; 10 | min-height: 100px; 11 | align-items: center; 12 | 13 | display: flex; 14 | flex-wrap: wrap; 15 | 16 | & > * { 17 | margin-top: 5px; 18 | margin-bottom: 5px; 19 | padding: 0 10px; 20 | } 21 | 22 | .link { 23 | color: black; 24 | text-decoration: none; 25 | 26 | &:focus { 27 | box-shadow: inset 0 0 0 2px rgba(0, 0, 0, 0.2); 28 | outline: 0; 29 | } 30 | 31 | &:hover { 32 | background-color: rgba(0, 0, 0, 0.1); 33 | } 34 | } 35 | 36 | .copyright { 37 | $line-height: 24px; 38 | line-height: $line-height; 39 | margin-left: auto; 40 | 41 | a { 42 | $off: 3px; 43 | display: inline-block; 44 | position: relative; 45 | color: inherit; 46 | text-decoration: none; 47 | z-index: 0; 48 | transition: color .1s ease; 49 | 50 | &::after { 51 | position: absolute; 52 | content: ''; 53 | display: block; 54 | height: 1px; 55 | bottom: 0; 56 | left: 0; 57 | right: 0; 58 | background-color: black; 59 | z-index: -1; 60 | transition: all .15s ease; 61 | } 62 | 63 | &:focus, &:hover { 64 | color: white; 65 | outline: 0; 66 | &::after { 67 | left: -$off; 68 | right: -$off; 69 | bottom: -$off; 70 | height: $line-height + 2 * $off; 71 | } 72 | } 73 | } 74 | } 75 | 76 | @media screen and (max-width: 500px) { 77 | .copyright { 78 | margin: 0; 79 | font-size: 16px; 80 | .part { 81 | display: block; 82 | margin: 10px 0; 83 | } 84 | 85 | .separator { 86 | display: none; 87 | } 88 | } 89 | } 90 | } 91 | } 92 | -------------------------------------------------------------------------------- /assets/zazuko/general.scss: -------------------------------------------------------------------------------- 1 | *::selection { 2 | background: $color-secondary; 3 | color: white; 4 | } 5 | 6 | body, button, input, textarea { 7 | font-family: $font-text; 8 | font-size: $fs-text; 9 | line-height: $fs-text + 4; 10 | font-weight: 300; 11 | 12 | background: white; 13 | } 14 | 15 | html, body { 16 | display: block; 17 | margin: 0; padding: 0; 18 | min-height: 100vh; 19 | } 20 | 21 | .main { 22 | display: flex; 23 | flex-direction: column; 24 | justify-content: space-between; 25 | min-height: 100vh; 26 | } 27 | 28 | .layout-width { 29 | width: $layout-width; 30 | max-width: 100vw; 31 | margin: auto; 32 | 33 | @media screen and (max-width: $mq-l) { 34 | width: 100%; 35 | padding: 0 $default-l-margin; 36 | } 37 | 38 | @media screen and (max-width: $mq-m) { 39 | padding: 0 $default-m-margin; 40 | } 41 | } 42 | 43 | .main-container { 44 | flex: 1; 45 | background-color: $bck-light; 46 | flex-direction: column; 47 | justify-content: center; 48 | align-items: center; 49 | display: flex; 50 | } 51 | 52 | .no-mobile { 53 | @media screen and (max-width: $mq-burger-nav) { 54 | display: none !important; 55 | } 56 | } 57 | 58 | .only-mobile { 59 | @media screen and (min-width: $mq-burger-nav) { 60 | display: none !important; 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /assets/zazuko/home-layout.scss: -------------------------------------------------------------------------------- 1 | .home-header { 2 | @include container(460px); 3 | margin-top: 40px; 4 | margin-bottom: 40px; 5 | 6 | @media screen and (max-width: $mq-s) { 7 | margin-top: 20px; 8 | margin-bottom: 20px; 9 | } 10 | 11 | .flex-container { 12 | display: flex; 13 | flex-direction: column; 14 | } 15 | 16 | .flex-item { 17 | margin: 10px 0; 18 | 19 | &.desc { 20 | display: flex; 21 | justify-content: space-between; 22 | align-items: center; 23 | padding: 0; 24 | 25 | font-size: 20px; 26 | line-height: 24px; 27 | padding-bottom: 5px; 28 | 29 | a { 30 | $off: 3px; 31 | $line-height: 24px; 32 | $stroke: 2px; 33 | display: inline-block; 34 | position: relative; 35 | color: inherit; 36 | text-decoration: none; 37 | font-family: monospace; 38 | white-space: nowrap; 39 | z-index: 0; 40 | transition: color .1s ease; 41 | 42 | &::after { 43 | position: absolute; 44 | content: ''; 45 | display: block; 46 | height: $stroke; 47 | bottom: -$stroke; 48 | left: 0; 49 | right: 0; 50 | background-color: $color-secondary; 51 | z-index: -1; 52 | transition: all .15s ease; 53 | } 54 | 55 | &:focus, &:hover { 56 | color: white; 57 | outline: 0; 58 | &::after { 59 | left: -$off; 60 | right: -$off; 61 | bottom: - $stroke - $off; 62 | height: $line-height + 2 * ($off + $stroke); 63 | } 64 | } 65 | } 66 | 67 | .tail { 68 | flex: 0 0 18px; 69 | width: 18px; height: 18px; 70 | background: $color-secondary; 71 | 72 | @media screen and (max-width: 460px + 2*20px) { 73 | display: none; 74 | } 75 | } 76 | } 77 | 78 | .autocomplete { 79 | position: relative; 80 | display: flex; 81 | 82 | input { 83 | flex: 1; 84 | position: relative; 85 | background-color: #FFF; 86 | border: 1px solid #979797; 87 | line-height: 22px; 88 | padding: 12px; 89 | width: 100%; 90 | font-size: 16px; 91 | 92 | &:focus { 93 | outline: 0; 94 | border-color: $color-secondary; 95 | box-shadow: inset 0 0 0 2px $color-secondary; 96 | z-index: 2; 97 | } 98 | } 99 | 100 | button { 101 | flex: 0; 102 | position: relative; 103 | background-color: white; 104 | padding: 0 12px; 105 | border: solid 1px #979797; 106 | margin-left: -1px; 107 | transition: color .15s ease; 108 | z-index: 0; 109 | 110 | &::after { 111 | position: absolute; 112 | content: ''; 113 | display: block; 114 | height: 0px; 115 | bottom: 0; 116 | left: 0; 117 | right: 0; 118 | background-color: $color-secondary; 119 | z-index: -1; 120 | transition: height .15s ease; 121 | } 122 | 123 | &:focus, &:hover { 124 | outline: 0; 125 | border-color: $color-secondary; 126 | color: white; 127 | z-index: 1; 128 | 129 | &::after { 130 | height: 46px; 131 | } 132 | } 133 | } 134 | 135 | &.open .results { display: block; } 136 | .results { 137 | display: none; 138 | position: absolute; 139 | top: 100%; 140 | left: 0; 141 | right: 0; 142 | box-shadow: 1px 2px 3px rgba(0, 0, 0, 0.15); 143 | 144 | li a { 145 | color: black; 146 | text-decoration: none; 147 | background: white; 148 | border: 1px solid #979797; 149 | margin-top: -1px; 150 | display: block; 151 | padding: 0 12px; 152 | font-size: 16px; 153 | line-height: 30px; 154 | 155 | // Small detail but I want to have those borders correctly displayed 156 | position: relative; 157 | z-index: 1; 158 | 159 | &:hover { 160 | border-left: solid 5px $color-secondary; 161 | padding-left: 12px - 4px; 162 | } 163 | 164 | &:focus { 165 | z-index: 2; 166 | background: $color-secondary; 167 | border-color: $color-secondary; 168 | color: white; 169 | outline: 0; 170 | } 171 | } 172 | } 173 | } 174 | 175 | &.title { 176 | display: flex; 177 | padding: 0; 178 | 179 | div { 180 | align-self: flex-end; 181 | 182 | h1 { 183 | position: relative; 184 | font-size: $fs-header; 185 | line-height: $fs-header; 186 | font-family: $font-header; 187 | font-weight: 700; 188 | 189 | @media screen and (max-width: $mq-s) { 190 | font-size: $fs-header - 20px; 191 | line-height: $fs-header - 20px; 192 | } 193 | } 194 | } 195 | } 196 | } 197 | } 198 | 199 | .home-content { 200 | padding-bottom: 100px; 201 | background: $color-primary; 202 | 203 | @media screen and (max-width: $mq-l) { 204 | padding-bottom: 0; 205 | } 206 | } 207 | -------------------------------------------------------------------------------- /assets/zazuko/main.scss: -------------------------------------------------------------------------------- 1 | $color-primary: #ffb15e; 2 | $color-primary-h: #ffe38d; 3 | $color-secondary: #ff441c; 4 | $color-secondary-h: #c30000; 5 | 6 | $color-text: #000000; 7 | $color-text-lighter: #4f4f4f; 8 | $bck-light: #fcfcfc; 9 | $line-light: #e5e5e5; 10 | $bck-dark: #202020; 11 | 12 | @mixin container($width: 940px, $gap: 20px) { 13 | width: $width + (2 * $gap); 14 | max-width: 100%; 15 | padding-left: $gap; 16 | padding-right: $gap; 17 | margin-left: auto; 18 | margin-right: auto; 19 | } 20 | 21 | $layout-width: 940px; 22 | $inner-layout-width: 700px; 23 | $mainline-height: 100px; 24 | $default-l-margin: 40px; 25 | $default-m-margin: 20px; 26 | $default-s-margin: 10px; 27 | 28 | // media queries rules 29 | $mq-l: $layout-width + (2 * $default-l-margin); 30 | $mq-m: 1000px; 31 | $mq-burger-nav: 950px; 32 | $mq-s: 800px; 33 | 34 | $fs-small: 15px; 35 | $fs-text: 18px; 36 | $fs-title: 24px; 37 | $fs-header: 60px; 38 | $fs-header-mini: 50px; 39 | 40 | $font-header: 'Playfair Display', serif; 41 | $font-text: 'Roboto', sans-serif; 42 | 43 | @import "reset"; 44 | @import "general"; 45 | @import "topbar"; 46 | @import "footer"; 47 | 48 | @import "home-layout"; 49 | @import "search-result"; 50 | @import "404-layout"; 51 | @import "md-content"; 52 | -------------------------------------------------------------------------------- /assets/zazuko/md-content.scss: -------------------------------------------------------------------------------- 1 | .md-content { 2 | padding: 100px 0; 3 | text-align: justify; 4 | 5 | * { 6 | &:last-child { 7 | margin-bottom: 0; 8 | } 9 | 10 | &:first-child { 11 | margin-top: 0; 12 | } 13 | } 14 | 15 | * > p { 16 | font-size: $fs-text; 17 | line-height: $fs-text + 6; 18 | } 19 | 20 | code { 21 | color: #ccc; 22 | background: #2d2d2d; 23 | font-family: Consolas,Monaco,Andale Mono,Ubuntu Mono,monospace; 24 | text-align: left; 25 | white-space: pre; 26 | word-spacing: normal; 27 | word-break: normal; 28 | word-wrap: normal; 29 | tab-size: 4; 30 | hyphens: none; 31 | font-size: 0.9em; 32 | padding: 2px; 33 | text-transform: initial; 34 | 35 | &.example { 36 | margin-bottom: 16px; 37 | padding: 0; 38 | display: block; 39 | white-space: normal; 40 | position: relative; 41 | 42 | &:hover { 43 | .copy { 44 | opacity: 1; 45 | } 46 | } 47 | 48 | .copy { 49 | opacity: 0; 50 | position: absolute; 51 | border-left: solid 1px #CCC; 52 | border-bottom: solid 1px #CCC; 53 | top: 0; 54 | right: 0; 55 | padding: 6px 12px; 56 | cursor: pointer; 57 | text-decoration: none; 58 | color: inherit; 59 | 60 | &:hover, &:focus { 61 | outline: 0; 62 | opacity: 1; 63 | background-color: $color-secondary; 64 | border-color: $color-secondary; 65 | color: white; 66 | } 67 | } 68 | 69 | .scroller { 70 | padding: 1.5em; 71 | overflow-x: auto; 72 | 73 | .line { 74 | max-width: 100%; 75 | white-space: nowrap; 76 | padding: 0 2em; 77 | &::before { 78 | margin-left: -2em; 79 | content: '$ ' 80 | } 81 | } 82 | 83 | .result { 84 | margin-top: 0.5em; 85 | white-space: pre; 86 | } 87 | } 88 | } 89 | } 90 | 91 | @media screen and (max-width: $mq-s) { 92 | padding: $default-l-margin 0 100px; 93 | } 94 | 95 | .content > *:not(.float) { 96 | margin-left: calc((#{$layout-width} - #{$inner-layout-width}) / 2); 97 | margin-right: calc((#{$layout-width} - #{$inner-layout-width}) / 2); 98 | 99 | @media screen and (max-width: $mq-m) { 100 | margin-left: 10%; 101 | margin-right: 10%; 102 | } 103 | 104 | @media screen and (max-width: $mq-s) { 105 | margin-left: $default-m-margin; 106 | margin-right: $default-m-margin; 107 | } 108 | } 109 | 110 | .float { 111 | margin-top: $default-l-margin; 112 | margin-bottom: $default-l-margin; 113 | padding: 0; 114 | background: $bck-light; 115 | 116 | border-radius: 3px; 117 | box-shadow: 0 5px 15px 0 rgba(0, 0, 0, .2); 118 | overflow: hidden; 119 | 120 | @media screen and (max-width: $mq-s) { 121 | margin: 0 $default-m-margin 16px $default-m-margin !important; 122 | width: auto !important; 123 | } 124 | 125 | &.is-small { width: 30%; } 126 | &.is-medium { width: 45%; } 127 | &.is-large { width: 100%; } 128 | 129 | &.is-left { 130 | float: left; 131 | margin-right: $default-l-margin; 132 | 133 | @media screen and (max-width: $mq-s) { 134 | float: none; 135 | } 136 | } 137 | 138 | &.is-right { 139 | float: right; 140 | margin-left: $default-l-margin; 141 | 142 | @media screen and (max-width: $mq-s) { 143 | float: none; 144 | } 145 | } 146 | 147 | &.has-padding { 148 | padding: $default-l-margin; 149 | } 150 | 151 | &> * { 152 | margin: 0 !important; 153 | } 154 | 155 | img { 156 | display: block; 157 | } 158 | 159 | blockquote { 160 | padding: 0; margin: 0; 161 | border: none; 162 | 163 | font-family: $font-header; 164 | color: $color-text; 165 | 166 | p { 167 | font-size: $fs-title; 168 | } 169 | } 170 | 171 | &.metadata { 172 | @media screen and (max-width: $mq-s) { 173 | margin-bottom: 30px !important; 174 | } 175 | 176 | .metadata-item:not(:last-child) { 177 | padding-bottom: $default-m-margin; 178 | } 179 | 180 | .label { 181 | color: $color-text-lighter; 182 | } 183 | 184 | .value { 185 | font-size: $fs-text; 186 | line-height: $fs-text + 4; 187 | font-weight: bold; 188 | 189 | a { 190 | text-decoration: none; 191 | } 192 | } 193 | } 194 | } 195 | 196 | // TODO: remove properly 197 | .header-anchor { 198 | display: none; 199 | } 200 | 201 | h1, h2, h3, h4, h5, h6 { 202 | text-align: left; 203 | } 204 | 205 | h1 { 206 | font-size: $fs-title; 207 | line-height: $fs-title + 6; 208 | margin: 24px 0; 209 | text-transform: uppercase; 210 | font-weight: bold; 211 | } 212 | 213 | h2 { 214 | font-size: $fs-title; 215 | line-height: $fs-title + 6; 216 | margin: 24px 0; 217 | font-weight: bold; 218 | } 219 | 220 | h3 { 221 | font-size: $fs-text; 222 | line-height: $fs-text + 6; 223 | margin: 24px 0; 224 | font-weight: bold; 225 | } 226 | 227 | h4, h5, h6 { 228 | font-size: $fs-text; 229 | line-height: $fs-text + 6; 230 | margin: 16px 0; 231 | } 232 | 233 | p { 234 | margin-bottom: 16px; 235 | } 236 | 237 | .extra-class { 238 | margin-bottom: 16px; 239 | } 240 | 241 | a { 242 | color: $color-secondary; 243 | 244 | .icon { 245 | display: inline-block; 246 | margin-left: 5px; 247 | } 248 | 249 | &:hover, &:focus { 250 | color: $color-secondary-h; 251 | } 252 | } 253 | 254 | hr { 255 | border: none; 256 | border-top: solid 1px $line-light; 257 | margin-bottom: 16px; 258 | } 259 | 260 | ul, ol { 261 | margin-bottom: 16px; 262 | list-style-position: outside; 263 | padding-left: 20px; 264 | 265 | li { 266 | padding-bottom: 4px; 267 | 268 | &:last-child { 269 | padding-bottom: 0; 270 | } 271 | } 272 | } 273 | 274 | ul { list-style-type: square; } 275 | ol { list-style-type: number; } 276 | 277 | img { 278 | max-width: 100%; 279 | } 280 | 281 | blockquote { 282 | background: $bck-light; 283 | padding: 0 16px; 284 | margin-bottom: 16px; 285 | color: $color-text-lighter; 286 | border-left: solid 1px $line-light; 287 | } 288 | 289 | table { 290 | display: block; 291 | overflow: auto; 292 | width: 100%; 293 | margin-bottom: 16px; 294 | 295 | td { 296 | border-bottom: 1px solid #e5e5e5; 297 | } 298 | 299 | th { 300 | font-weight: bold; 301 | } 302 | 303 | th, td { 304 | padding: 5px 16px; 305 | } 306 | 307 | &.toc { 308 | th, td { 309 | &:first-child { 310 | text-align: right; 311 | border-right: 1px solid #e5e5e5; 312 | a { 313 | text-decoration: none; 314 | } 315 | } 316 | padding: 5px 16px; 317 | } 318 | } 319 | } 320 | 321 | pre { 322 | line-height: 20px; 323 | } 324 | } 325 | 326 | strong { 327 | font-weight: bold; 328 | } 329 | 330 | em { 331 | font-style: italic; 332 | } 333 | -------------------------------------------------------------------------------- /assets/zazuko/reset.scss: -------------------------------------------------------------------------------- 1 | /** 2 | * http://cssreset.com 3 | */ 4 | 5 | html, body, div, span, applet, object, 6 | iframe,h1, h2, h3, h4, h5, h6, p, 7 | blockquote, pre,a, abbr, acronym, 8 | address, big, cite, code,del, dfn, 9 | em, img, ins, kbd, q, s, samp, small, 10 | strike, strong, sub, sup, tt, var,b, 11 | u, i, center,dl, dt, dd, ol, ul, li, 12 | fieldset, form, label, legend,table, 13 | caption, tbody, tfoot, thead, tr, th, 14 | td,article, aside, canvas, details, 15 | embed, figure, figcaption, footer, 16 | header, hgroup, menu, nav, output, 17 | ruby, section, summary, time, mark, 18 | audio, video { 19 | margin: 0; padding: 0; 20 | border: 0; 21 | font-size: 100%; 22 | font: inherit; 23 | vertical-align: baseline; 24 | } 25 | 26 | /** 27 | * HTML5 display-role reset for older browsers 28 | */ 29 | 30 | article, aside, details, figcaption, figure, 31 | footer, header, hgroup, menu, nav, section { 32 | display: block; 33 | } 34 | 35 | body { 36 | line-height: 1; 37 | } 38 | 39 | ol, ul { 40 | list-style: none; 41 | } 42 | 43 | blockquote, q { 44 | quotes: none; 45 | } 46 | 47 | blockquote:before, 48 | blockquote:after, 49 | q:before, q:after { 50 | content: ''; 51 | content: none; 52 | } 53 | 54 | table { 55 | border-collapse: collapse; 56 | border-spacing: 0; 57 | } 58 | 59 | input, button { 60 | margin: 0; 61 | } 62 | 63 | button { 64 | cursor: pointer; 65 | } 66 | 67 | /** 68 | * Framework common style 69 | */ 70 | 71 | * { 72 | -moz-box-sizing: border-box; 73 | -webkit-box-sizing: border-box; 74 | -o-box-sizing: border-box; 75 | box-sizing: border-box; 76 | } 77 | -------------------------------------------------------------------------------- /assets/zazuko/search-result.scss: -------------------------------------------------------------------------------- 1 | .main-results { 2 | padding: 32px 0; 3 | background-color: white; 4 | border-top: 1px solid $line-light; 5 | border-bottom: 1px solid $line-light; 6 | align-self: stretch; 7 | 8 | // TODO(sandhose): this is confusing, but this part ensures it scrolls and 9 | // works correctly on mobile 10 | max-width: 100%; 11 | overflow-x: auto; 12 | text-align: center; 13 | section { 14 | text-align: initial; 15 | display: inline-block; 16 | } 17 | 18 | .big { 19 | white-space: nowrap; 20 | margin: 0 20px; 21 | 22 | .line { 23 | position: relative; 24 | cursor: pointer; 25 | 26 | a { 27 | $off: 2px; 28 | $line-height: 28px; 29 | $stroke: 2px; 30 | display: inline-block; 31 | position: relative; 32 | color: inherit; 33 | text-decoration: none; 34 | // font-family: monospace; 35 | white-space: nowrap; 36 | z-index: 0; 37 | transition: color .1s ease; 38 | 39 | &::after { 40 | position: absolute; 41 | content: ''; 42 | display: block; 43 | height: $stroke; 44 | bottom: -$stroke; 45 | left: 0; 46 | right: 0; 47 | background-color: $color-secondary; 48 | z-index: -1; 49 | transition: all .15s ease; 50 | } 51 | 52 | &:focus, &:hover { 53 | color: white; 54 | outline: 0; 55 | &::after { 56 | left: -$off; 57 | right: -$off; 58 | bottom: - $stroke - $off; 59 | height: $line-height + 2 * ($off + $stroke); 60 | } 61 | } 62 | } 63 | 64 | & > span { 65 | color: #5D5D5D; 66 | } 67 | 68 | &:hover { 69 | .tooltip { 70 | opacity: 1; 71 | transform: translateY(-20px); 72 | } 73 | } 74 | 75 | .tooltip { 76 | pointer-events: none; 77 | transition: opacity ease .1s, transform ease .1s; 78 | opacity: 0; 79 | transform: translateY(-40px); 80 | color: white; 81 | font-size: 12px; 82 | line-height: 24px; 83 | background-color: rgba(0, 0, 0, 0.7); 84 | position: absolute; 85 | padding: 0 4px; 86 | border-radius: 3px; 87 | top: 0; 88 | right: 0; 89 | } 90 | } 91 | 92 | text-align: right; 93 | font-size: 20px; 94 | line-height: 28px; 95 | font-weight: 500; 96 | 97 | @media screen and (max-width: $mq-s) { 98 | text-align: left; 99 | .line .tooltip { 100 | right: unset; 101 | left: 0; 102 | } 103 | } 104 | } 105 | 106 | .small { 107 | margin: 28px 10px 0; 108 | display: flex; 109 | flex-wrap: wrap; 110 | max-width: 100vw; 111 | position: relative; 112 | 113 | & > div { 114 | margin: 5px 10px; 115 | h3 { 116 | color: #212121; 117 | font-size: 16px; 118 | font-weight: 500; 119 | line-height: 22px; 120 | } 121 | 122 | p a { 123 | text-decoration: none; 124 | color: $color-secondary; 125 | font-weight: 400; 126 | font-size: 16px; 127 | } 128 | } 129 | 130 | .prefix-clipboard-container { 131 | cursor: pointer; 132 | 133 | &:hover { 134 | .tooltip { 135 | opacity: 1; 136 | transform: translateY(-20px); 137 | } 138 | } 139 | 140 | .tooltip { 141 | pointer-events: none; 142 | transition: opacity ease .1s, transform ease .1s; 143 | opacity: 0; 144 | transform: translateY(-40px); 145 | color: white; 146 | font-size: 12px; 147 | line-height: 24px; 148 | background-color: rgba(0, 0, 0, 0.7); 149 | position: absolute; 150 | padding: 0 4px; 151 | border-radius: 3px; 152 | top: 0; 153 | right: 0; 154 | } 155 | } 156 | } 157 | } 158 | 159 | .search-results { 160 | @include container; 161 | 162 | background-color: $bck-light; 163 | font-size: 14px; 164 | line-height: 20px; 165 | font-weight: 400; 166 | margin-bottom: 40px; 167 | 168 | .grid { 169 | .row { 170 | display: flex; 171 | flex-wrap: wrap; 172 | justify-content: space-between; 173 | border-bottom: 1px solid $line-light; 174 | 175 | .predicate { 176 | padding: 10px 10px 10px 0; 177 | word-break: break-all; 178 | } 179 | 180 | .terms { 181 | flex: 0 1 720px; 182 | border-left: 1px solid $line-light; 183 | margin-left: auto; 184 | 185 | .term { 186 | margin-top: -1px; 187 | border-top: 1px solid $line-light; 188 | padding: 10px 0 10px 20px; 189 | color: rgba(0,0,0,0.60); 190 | letter-spacing: 0.25px; 191 | text-align: justify; 192 | line-height: 20px; 193 | 194 | a, .language { 195 | color: #FF441C; 196 | } 197 | } 198 | 199 | @media screen and (max-width: $mq-m) { 200 | flex-basis: 600px; 201 | } 202 | 203 | @media screen and (max-width: $mq-s) { 204 | flex-basis: 500px; 205 | } 206 | } 207 | 208 | @media screen and (max-width: 500px + 55px) { 209 | border-bottom-color: #999; 210 | 211 | .terms { 212 | flex-basis: 100%; 213 | border-left: 0; 214 | 215 | .term { 216 | padding: 10px 0; 217 | } 218 | } 219 | } 220 | } 221 | } 222 | } 223 | -------------------------------------------------------------------------------- /assets/zazuko/topbar.scss: -------------------------------------------------------------------------------- 1 | .topbar-container { 2 | background-color: $color-primary; 3 | border-bottom: solid 1px rgba(0, 0, 0, 0.2); 4 | 5 | .topbar { 6 | @include container; 7 | } 8 | 9 | .logo { 10 | display: inline-block; 11 | position: relative; 12 | padding: 0 30px; 13 | line-height: $mainline-height; 14 | white-space: nowrap; 15 | 16 | font-weight: bold; 17 | text-transform: uppercase; 18 | background: $bck-light; 19 | z-index: 1; 20 | text-decoration: none; 21 | color: #222; 22 | margin-bottom: -1px; 23 | 24 | img { 25 | position: relative; 26 | top: -2px; 27 | display: inline-block; 28 | width: 140px; 29 | vertical-align: middle; 30 | margin-right: 10px; 31 | } 32 | 33 | @media screen and (max-width: $mq-s) { 34 | img { 35 | margin-right: 0; 36 | } 37 | } 38 | 39 | @media screen and (max-width: 400px) { 40 | text-align: center; 41 | width: 100%; 42 | line-height: 80px; 43 | font-size: 13px; 44 | img { 45 | width: 90px; 46 | } 47 | } 48 | } 49 | } 50 | 51 | .github-corner { 52 | height: 100px; 53 | display: block; 54 | position: absolute; 55 | top: 0; 56 | right: 0; 57 | overflow: hidden; 58 | z-index: 2; 59 | 60 | svg { 61 | height: 120px; 62 | width: 120px; 63 | } 64 | 65 | &:hover .octo-arm { 66 | animation:octocat-wave 560ms ease-in-out; 67 | } 68 | 69 | @media screen and (max-width: $mq-s) { 70 | svg { 71 | height: 90px; 72 | width: 90px; 73 | } 74 | 75 | &:hover .octo-arm { animation: none; } 76 | .octo-arm { animation:octocat-wave 560ms ease-in-out; } 77 | } 78 | 79 | @media screen and (max-width: 400px) { 80 | svg { 81 | height: 70px; 82 | width: 70px; 83 | } 84 | } 85 | } 86 | 87 | @keyframes octocat-wave { 88 | 0%, 100% { transform:rotate(0); } 89 | 20%, 60% { transform:rotate(-25deg); } 90 | 40%, 80% { transform:rotate(10deg); } 91 | } 92 | -------------------------------------------------------------------------------- /build-resources.js: -------------------------------------------------------------------------------- 1 | // only do the thing when called directly (node this-script) 2 | if (require.main === module) { 3 | Promise.resolve().then(buildResources) 4 | } 5 | 6 | module.exports = buildResources 7 | 8 | async function buildResources () { 9 | const debug = require('debug')('prefix-server') 10 | const path = require('path') 11 | const fs = require('fs') 12 | const { promisify } = require('util') 13 | const zlib = require('zlib') 14 | const writeFile = promisify(fs.writeFile) 15 | const gzip = promisify(zlib.gzip) 16 | 17 | debug('preparing API data') 18 | const { prepareData } = require('./api/utils') 19 | 20 | const dataFiles = await prepareData() 21 | 22 | const fileNames = Object.entries(dataFiles) 23 | 24 | for (const [keyName, data] of fileNames) { 25 | const extraFilePath = path.resolve(__dirname, `./api/datafiles/${keyName}.json.gz`) 26 | const compressed = await gzip(JSON.stringify(data)) 27 | await writeFile(extraFilePath, compressed) 28 | debug(`wrote API data to ${extraFilePath}`) 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /components/Autocomplete.vue: -------------------------------------------------------------------------------- 1 | 57 | 58 | 196 | -------------------------------------------------------------------------------- /components/CurlExample.vue: -------------------------------------------------------------------------------- 1 | 28 | 29 | 95 | 96 | 101 | -------------------------------------------------------------------------------- /components/DetailResults.vue: -------------------------------------------------------------------------------- 1 | 27 | 28 | 104 | -------------------------------------------------------------------------------- /components/MainResults.vue: -------------------------------------------------------------------------------- 1 | 70 | 71 | 186 | -------------------------------------------------------------------------------- /components/PageFooter.vue: -------------------------------------------------------------------------------- 1 | 29 | 30 | 40 | -------------------------------------------------------------------------------- /components/PageHeader.vue: -------------------------------------------------------------------------------- 1 | 23 | 24 | 29 | -------------------------------------------------------------------------------- /components/Predicate.vue: -------------------------------------------------------------------------------- 1 | 22 | 23 | 45 | 46 | 59 | -------------------------------------------------------------------------------- /components/Term.vue: -------------------------------------------------------------------------------- 1 | 33 | 34 | 74 | -------------------------------------------------------------------------------- /components/Terms.vue: -------------------------------------------------------------------------------- 1 | 6 | 7 | 23 | -------------------------------------------------------------------------------- /cypress.json: -------------------------------------------------------------------------------- 1 | { 2 | "baseUrl": "http://localhost:3000", 3 | "fixturesFolder": "test/e2e/fixtures", 4 | "integrationFolder": "test/e2e/integration", 5 | "pluginsFile": "test/e2e/plugins/index.js", 6 | "screenshotsFolder": "test/e2e/screenshots", 7 | "supportFile": "test/e2e/support/index.js", 8 | "videosFolder": "test/e2e/videos" 9 | } 10 | -------------------------------------------------------------------------------- /layouts/default.vue: -------------------------------------------------------------------------------- 1 | 8 | 9 | 28 | -------------------------------------------------------------------------------- /layouts/error.vue: -------------------------------------------------------------------------------- 1 | 14 | 15 | 39 | -------------------------------------------------------------------------------- /nuxt.config.js: -------------------------------------------------------------------------------- 1 | export default { 2 | /* 3 | ** Headers of the page 4 | */ 5 | head: { 6 | titleTemplate: '%s - Zazuko Prefix Server', 7 | title: 'Zazuko Prefix Server', 8 | meta: [ 9 | { charset: 'utf-8' }, 10 | { name: 'viewport', content: 'width=device-width, initial-scale=1' }, 11 | { name: 'msapplication-TileColor', content: '#ffb15e' }, 12 | { nane: 'theme-color', content: '#ffb15e' }, 13 | { hid: 'description', name: 'description', content: process.env.npm_package_description || '' } 14 | ], 15 | link: [ 16 | { rel: 'icon', type: 'image/x-icon', href: '/favicon/favicon.ico' }, 17 | { rel: 'apple-touch-icon', sizes: '180x180', href: '/favicon/apple-touch-icon.png' }, 18 | { rel: 'icon', type: 'image/png', sizes: '32x32', href: '/favicon/favicon-32x32.png' }, 19 | { rel: 'icon', type: 'image/png', sizes: '16x16', href: '/favicon/favicon-16x16.png' }, 20 | { rel: 'manifest', href: '/favicon/site.webmanifest' }, 21 | { 22 | rel: 'stylesheet', 23 | href: 'https://fonts.googleapis.com/css?family=Playfair+Display:400,700|Roboto:300,400,500,700|Material+Icons' 24 | }, 25 | { 26 | rel: 'search', 27 | type: 'application/opensearchdescription+xml', 28 | href: 'opensearch.xml', 29 | title: 'Zazuko Prefix Server' 30 | } 31 | ] 32 | }, 33 | env: { 34 | version: process.env.APP_VERSION 35 | ? { 36 | name: process.env.APP_VERSION, 37 | commit: process.env.APP_COMMIT, 38 | url: `https://github.com/zazuko/prefix-server/tree/${process.env.APP_COMMIT}` 39 | } 40 | : null 41 | }, 42 | /* 43 | ** Customize the progress-bar color 44 | */ 45 | loading: { color: '#ff441c' }, 46 | /* 47 | ** Global CSS 48 | */ 49 | css: [ 50 | '@/assets/zazuko/main.scss' 51 | ], 52 | serverMiddleware: [ 53 | '@/api/etag-middleware', 54 | '@/api/' 55 | ], 56 | /* 57 | ** Plugins to load before mounting the App 58 | */ 59 | plugins: [ 60 | '@/plugins/clipboard' 61 | ], 62 | /* 63 | ** Nuxt.js modules 64 | */ 65 | modules: [ 66 | '@nuxtjs/axios' 67 | ], 68 | /* 69 | ** Axios module configuration 70 | ** See https://axios.nuxtjs.org/options 71 | */ 72 | axios: { 73 | }, 74 | /* 75 | ** Build configuration 76 | */ 77 | build: { 78 | /* 79 | ** You can extend webpack config here 80 | */ 81 | extend (config, ctx) { 82 | }, 83 | transpile: ['feather-icon-literals'] 84 | }, 85 | hooks: { 86 | build: {} 87 | }, 88 | render: { 89 | etag: false 90 | } 91 | } 92 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "prefix-server", 3 | "version": "2023.12.9", 4 | "license": "AGPLv3", 5 | "description": "RDF prefix / namespaces resolution", 6 | "author": "Zazuko GmbH", 7 | "private": true, 8 | "scripts": { 9 | "lint": "eslint --ext .js,.vue .", 10 | "precommit": "npm run lint", 11 | "dev": "nuxt", 12 | "build": "nuxt build", 13 | "build:modern": "nuxt build --modern=server", 14 | "build-data": "DEBUG=prefix-server node ./build-resources", 15 | "start": "nuxt-start", 16 | "generate": "nuxt generate", 17 | "e2e:open": "cypress open", 18 | "e2e:test": "cypress run" 19 | }, 20 | "dependencies": { 21 | "@nuxtjs/axios": "^5.13.6", 22 | "@rdfjs/data-model": "^1.3.4", 23 | "@rdfjs/to-ntriples": "^2", 24 | "@zazuko/vocabularies": "^3.1.0", 25 | "debug": "^4.3.4", 26 | "express": "^4.19.2", 27 | "express-preconditions": "^1.0.5", 28 | "feather-icon-literals": "^1.0.0-rc.11", 29 | "fuse.js": "^6.6.2", 30 | "lodash": "^4.17.21", 31 | "middleware-async": "^1.3.6", 32 | "nuxt-start": "^2.15.8", 33 | "query-string": "^7.1.1", 34 | "string-hash": "^1.1.3", 35 | "v-clipboard": "^2.2.3", 36 | "xss": "^1.0.14" 37 | }, 38 | "devDependencies": { 39 | "@cypress/browserify-preprocessor": "^3.0.2", 40 | "@cypress/snapshot": "^2.1.7", 41 | "@nuxtjs/eslint-config": "^6.0.1", 42 | "cypress": "^8.7.0", 43 | "eslint": "^7.32.0", 44 | "eslint-config-standard": "^16.0.3", 45 | "eslint-plugin-cypress": "^2.12.1", 46 | "eslint-plugin-nuxt": "^2.0.0", 47 | "eslint-plugin-unicorn": "^35.0.0", 48 | "eslint-plugin-vue": "^7.20.0", 49 | "nuxt": "^2.16.3", 50 | "sass": "^1.55.0", 51 | "sass-loader": "^10.3.1" 52 | }, 53 | "engines": { 54 | "node": ">=14", 55 | "npm": ">=7" 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /pages/_.vue: -------------------------------------------------------------------------------- 1 | 39 | 40 | 179 | -------------------------------------------------------------------------------- /pages/about.vue: -------------------------------------------------------------------------------- 1 | 59 | 60 | 69 | -------------------------------------------------------------------------------- /pages/api.vue: -------------------------------------------------------------------------------- 1 | 180 | 181 | 206 | -------------------------------------------------------------------------------- /pages/namespaces.vue: -------------------------------------------------------------------------------- 1 | 9 | -------------------------------------------------------------------------------- /pages/prefix/_.vue: -------------------------------------------------------------------------------- 1 | 64 | 65 | 100 | 101 | 106 | -------------------------------------------------------------------------------- /pages/prefixes.vue: -------------------------------------------------------------------------------- 1 | 22 | 23 | 38 | -------------------------------------------------------------------------------- /pages/search.vue: -------------------------------------------------------------------------------- 1 | 12 | -------------------------------------------------------------------------------- /plugins/clipboard.js: -------------------------------------------------------------------------------- 1 | import Vue from 'vue' 2 | import Clipboard from 'v-clipboard' 3 | 4 | Vue.use(Clipboard) 5 | -------------------------------------------------------------------------------- /snapshots.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | "__version": "8.7.0", 3 | "Search": { 4 | "should be available on homepage": { 5 | "1": [ 6 | "rdau:P60827 (is commissioning body of)", 7 | "rdau:P60881 (is remix artist of)", 8 | "rdau:P60882 (is casting director of)", 9 | "rdau:P60816 (is degree committee member of)", 10 | "rdau:P60835 (is participant in treaty of)", 11 | "rdau:P60837 (is researcher of)", 12 | "rdau:P60850 (is organizer of)", 13 | "rdau:P60870 (is editorial director of)", 14 | "rdau:P60872 (is founder agent of resource of)", 15 | "rdau:P60843 (is choral conductor of)" 16 | ], 17 | "2": [ 18 | "dbo:Person (person)", 19 | "crm:E21_Person (Person)", 20 | "dbo:person (person)", 21 | "rico:Person (Person)", 22 | "as:Person (Person)", 23 | "prov:Person (Person)" 24 | ], 25 | "3": [ 26 | "rdfs:", 27 | "rdfs:Container (Container)", 28 | "rdfs:Datatype (Datatype)", 29 | "rdfs:seeAlso (seeAlso)", 30 | "rdfs:comment (comment)", 31 | "rdfs:isDefinedBy (isDefinedBy)", 32 | "rdfs:label (label)", 33 | "rdfs:domain (domain)", 34 | "rdfs:Resource (Resource)", 35 | "rdfs:range (range)" 36 | ] 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /static/favicon/android-chrome-192x192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zazuko/prefix-server/fb21cb85a3a105708a47ef2bbecda8234846c7e1/static/favicon/android-chrome-192x192.png -------------------------------------------------------------------------------- /static/favicon/android-chrome-512x512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zazuko/prefix-server/fb21cb85a3a105708a47ef2bbecda8234846c7e1/static/favicon/android-chrome-512x512.png -------------------------------------------------------------------------------- /static/favicon/apple-touch-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zazuko/prefix-server/fb21cb85a3a105708a47ef2bbecda8234846c7e1/static/favicon/apple-touch-icon.png -------------------------------------------------------------------------------- /static/favicon/favicon-16x16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zazuko/prefix-server/fb21cb85a3a105708a47ef2bbecda8234846c7e1/static/favicon/favicon-16x16.png -------------------------------------------------------------------------------- /static/favicon/favicon-32x32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zazuko/prefix-server/fb21cb85a3a105708a47ef2bbecda8234846c7e1/static/favicon/favicon-32x32.png -------------------------------------------------------------------------------- /static/favicon/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zazuko/prefix-server/fb21cb85a3a105708a47ef2bbecda8234846c7e1/static/favicon/favicon.ico -------------------------------------------------------------------------------- /static/favicon/site.webmanifest: -------------------------------------------------------------------------------- 1 | {"name":"","short_name":"","icons":[{"src":"/android-chrome-192x192.png","sizes":"192x192","type":"image/png"},{"src":"/android-chrome-512x512.png","sizes":"512x512","type":"image/png"}],"theme_color":"#ffffff","background_color":"#ffffff","display":"standalone"} -------------------------------------------------------------------------------- /static/og-home.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zazuko/prefix-server/fb21cb85a3a105708a47ef2bbecda8234846c7e1/static/og-home.png -------------------------------------------------------------------------------- /static/opensearch.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | Zazuko Prefix Server 4 | https://prefix.zazuko.com/favicon/favicon-16x16.pnx 5 | 6 | 7 | rdf namespace prefix 8 | 9 | -------------------------------------------------------------------------------- /static/prefix-server-logo.svg: -------------------------------------------------------------------------------- 1 | 2 | 19 | 21 | 22 | 24 | image/svg+xml 25 | 27 | 28 | 29 | 30 | 31 | 33 | 57 | 60 | 66 | 71 | 72 | 73 | -------------------------------------------------------------------------------- /static/zazuko-logo.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test/e2e/integration/api_spec.js: -------------------------------------------------------------------------------- 1 | describe('/api/v1', () => { 2 | it('/health', () => { 3 | cy.request('/api/v1/health').then((response) => { 4 | expect(response.status).to.eq(200) 5 | expect(response.body).to.eq('ok') 6 | }) 7 | }) 8 | 9 | describe('/expand', () => { 10 | it('should fail on bad requests', () => { 11 | cy.request({ 12 | url: '/api/v1/expand?q=', 13 | failOnStatusCode: false 14 | }).then((response) => { 15 | expect(response.status).to.eq(400) 16 | expect(response.body).to.deep.equal({ help: '/api/v1/expand?q=…' }) 17 | }) 18 | cy.request({ 19 | url: '/api/v1/expand', 20 | failOnStatusCode: false 21 | }).then((response) => { 22 | expect(response.status).to.eq(400) 23 | expect(response.body).to.deep.equal({ help: '/api/v1/expand?q=…' }) 24 | }) 25 | }) 26 | 27 | it('should succeed with expandable prefixes', () => { 28 | cy.request('/api/v1/expand?q=schema:Person').then((response) => { 29 | expect(response.status).to.eq(200) 30 | expect(response.body).to.deep.equal({ success: true, value: 'http://schema.org/Person' }) 31 | }) 32 | cy.request('/api/v1/expand?q=rdfs:Class').then((response) => { 33 | expect(response.status).to.eq(200) 34 | expect(response.body).to.deep.equal({ success: true, value: 'http://www.w3.org/2000/01/rdf-schema#Class' }) 35 | }) 36 | }) 37 | }) 38 | 39 | describe('/shrink', () => { 40 | it('should fail on bad requests', () => { 41 | cy.request({ 42 | url: '/api/v1/shrink?q=', 43 | failOnStatusCode: false 44 | }).then((response) => { 45 | expect(response.status).to.eq(400) 46 | expect(response.body).to.deep.equal({ help: '/api/v1/shrink?q=…' }) 47 | }) 48 | cy.request({ 49 | url: '/api/v1/shrink', 50 | failOnStatusCode: false 51 | }).then((response) => { 52 | expect(response.status).to.eq(400) 53 | expect(response.body).to.deep.equal({ help: '/api/v1/shrink?q=…' }) 54 | }) 55 | }) 56 | 57 | it('should succeed with shrinkable prefixes', () => { 58 | cy.request('/api/v1/shrink?q=http://schema.org/Person').then((response) => { 59 | expect(response.status).to.eq(200) 60 | expect(response.body).to.deep.equal({ success: true, value: 'schema:Person' }) 61 | }) 62 | const iri = 'http://www.w3.org/2000/01/rdf-schema#Class' 63 | const encodedIRI = encodeURIComponent(iri) 64 | cy.request(`/api/v1/shrink?q=${encodedIRI}`).then((response) => { 65 | expect(response.status).to.eq(200) 66 | expect(response.body).to.deep.equal({ success: true, value: 'rdfs:Class' }) 67 | }) 68 | }) 69 | 70 | it('should fail with non-shrinkable prefixes', () => { 71 | cy.request({ 72 | url: '/api/v1/shrink?q=http://example.org/Person', 73 | failOnStatusCode: false 74 | }).then((response) => { 75 | expect(response.status).to.eq(404) 76 | expect(response.body).to.deep.equal({ success: false }) 77 | }) 78 | const iri = 'http://www.w3.org/2000/01/rdf-schema#Class' 79 | cy.request({ 80 | url: `/api/v1/shrink?q=${iri}`, 81 | failOnStatusCode: false 82 | }).then((response) => { 83 | expect(response.status).to.eq(404) 84 | expect(response.body).to.deep.equal({ success: false }) 85 | }) 86 | }) 87 | }) 88 | 89 | describe('/suggest', () => { 90 | it('should suggest empty', () => { 91 | cy.request('/api/v1/suggest?q=').then((response) => { 92 | expect(response.status).to.eq(200) 93 | expect(response.body).to.deep.equal([]) 94 | }) 95 | }) 96 | it('should suggest results', () => { 97 | cy.request('/api/v1/suggest?q=Person').then((response) => { 98 | expect(response.status).to.eq(200) 99 | response.body.slice(0, 8).forEach((term) => { 100 | expect(term.toLowerCase()).to.contain('person') 101 | }) 102 | }) 103 | cy.request('/api/v1/suggest?q=person').then((response) => { 104 | expect(response.status).to.eq(200) 105 | response.body.slice(0, 8).forEach((term) => { 106 | expect(term.toLowerCase()).to.contain('person') 107 | }) 108 | }) 109 | }) 110 | }) 111 | 112 | describe('/autocomplete', () => { 113 | it('should suggest prefixes starting with query', () => { 114 | cy.request('/api/v1/autocomplete?q=').then((response) => { 115 | expect(response.status).to.eq(200) 116 | expect(response.body).to.contain('rdf:') 117 | expect(response.body).to.contain('schema:') 118 | expect(response.body).to.contain('xsd:') 119 | }) 120 | cy.request('/api/v1/autocomplete?q=r').then((response) => { 121 | expect(response.status).to.eq(200) 122 | expect(response.body.filter(p => p.startsWith('r'))).to.have.length(response.body.length) 123 | }) 124 | }) 125 | it('should be case insensitive', () => { 126 | cy.request('/api/v1/autocomplete?q=schema:a').then((response) => { 127 | expect(response.status).to.eq(200) 128 | expect(response.body).to.contain('schema:about') 129 | expect(response.body).to.contain('schema:AboutPage') 130 | }) 131 | }) 132 | it('should be case sensitive', () => { 133 | cy.request('/api/v1/autocomplete?q=schema:a&case=true').then((response) => { 134 | expect(response.status).to.eq(200) 135 | expect(response.body).to.contain('schema:about') 136 | expect(response.body).not.to.contain('schema:AboutPage') 137 | }) 138 | cy.request('/api/v1/autocomplete?q=schema:A&case=true').then((response) => { 139 | expect(response.status).to.eq(200) 140 | expect(response.body).not.to.contain('schema:about') 141 | expect(response.body).to.contain('schema:AboutPage') 142 | }) 143 | }) 144 | it('should match type', () => { 145 | cy.request('/api/v1/autocomplete?q=schema:a&type=rdf:Property').then((response) => { 146 | expect(response.status).to.eq(200) 147 | expect(response.body).to.contain('schema:about') 148 | expect(response.body).not.to.contain('schema:AboutPage') 149 | }) 150 | cy.request('/api/v1/autocomplete?q=schema:A&type=rdfs:Class').then((response) => { 151 | expect(response.status).to.eq(200) 152 | expect(response.body).not.to.contain('schema:about') 153 | expect(response.body).to.contain('schema:AboutPage') 154 | }) 155 | cy.request('/api/v1/autocomplete?q=schema:a&type=rdf:property').then((response) => { 156 | expect(response.status).to.eq(200) 157 | expect(response.body).to.contain('schema:about') 158 | expect(response.body).not.to.contain('schema:AboutPage') 159 | }) 160 | cy.request('/api/v1/autocomplete?q=schema:A&type=rdfs:class').then((response) => { 161 | expect(response.status).to.eq(200) 162 | expect(response.body).not.to.contain('schema:about') 163 | expect(response.body).to.contain('schema:AboutPage') 164 | }) 165 | }) 166 | it('should match type and case', () => { 167 | cy.request('/api/v1/autocomplete?q=schema:a&type=rdf:Property&case=true').then((response) => { 168 | expect(response.status).to.eq(200) 169 | expect(response.body).to.contain('schema:about') 170 | expect(response.body).not.to.contain('schema:AboutPage') 171 | }) 172 | cy.request('/api/v1/autocomplete?q=schema:A&type=rdfs:Class&case=true').then((response) => { 173 | expect(response.status).to.eq(200) 174 | expect(response.body).not.to.contain('schema:about') 175 | expect(response.body).to.contain('schema:AboutPage') 176 | }) 177 | cy.request('/api/v1/autocomplete?q=schema:a&type=rdfs:Class&case=true').then((response) => { 178 | expect(response.status).to.eq(200) 179 | expect(response.body).to.have.length(0) 180 | }) 181 | cy.request('/api/v1/autocomplete?q=schema:A&type=rdf:Property&case=true').then((response) => { 182 | expect(response.status).to.eq(200) 183 | expect(response.body).to.have.length(0) 184 | }) 185 | cy.request('/api/v1/autocomplete?q=schema:a&type=rdf:property&case=true').then((response) => { 186 | expect(response.status).to.eq(200) 187 | expect(response.body).to.have.length(0) 188 | }) 189 | cy.request('/api/v1/autocomplete?q=schema:A&type=rdfs:class&case=true').then((response) => { 190 | expect(response.status).to.eq(200) 191 | expect(response.body).to.have.length(0) 192 | }) 193 | }) 194 | describe('expands', () => { 195 | it('prefixes starting with query', () => { 196 | cy.request('/api/v1/autocomplete?q=rd&expand=true').then((response) => { 197 | expect(response.status).to.eq(200) 198 | expect(response.body).to.contain('http://www.w3.org/1999/02/22-rdf-syntax-ns#') 199 | expect(response.body).to.contain('http://www.w3.org/2000/01/rdf-schema#') 200 | }) 201 | }) 202 | it('case sensitive', () => { 203 | cy.request('/api/v1/autocomplete?expand=true&q=schema:a&case=true').then((response) => { 204 | expect(response.status).to.eq(200) 205 | expect(response.body).to.contain('http://schema.org/about') 206 | expect(response.body).not.to.contain('http://schema.org/AboutPage') 207 | }) 208 | }) 209 | it('match type and case', () => { 210 | cy.request('/api/v1/autocomplete?q=schema:a&type=rdf:Property&expand=true&case=true').then((response) => { 211 | expect(response.status).to.eq(200) 212 | expect(response.body).to.contain('http://schema.org/about') 213 | expect(response.body).not.to.contain('http://schema.org/AboutPage') 214 | }) 215 | }) 216 | }) 217 | describe('prefixes', () => { 218 | it('get a list of prefixes', () => { 219 | cy.request('/api/v1/prefixes').then((response) => { 220 | expect(response.status).to.eq(200) 221 | expect(Object.entries(response.body).length).to.be.greaterThan(0) 222 | }) 223 | }) 224 | }) 225 | }) 226 | }) 227 | -------------------------------------------------------------------------------- /test/e2e/integration/home_spec.js: -------------------------------------------------------------------------------- 1 | const searchField = () => cy.get('.search-field-container input') 2 | 3 | describe('Home', () => { 4 | before(() => { 5 | cy.visit('/') 6 | }) 7 | beforeEach(() => { 8 | searchField().focus().clear() 9 | }) 10 | 11 | it('should redirect /namespaces to /prefixes', () => { 12 | cy.visit('/namespaces') 13 | cy.url().should('include', '/prefixes') 14 | }) 15 | }) 16 | -------------------------------------------------------------------------------- /test/e2e/integration/prefixes_spec.js: -------------------------------------------------------------------------------- 1 | const _ = require('lodash') 2 | const collectResults = (result) => { 3 | const results = Cypress._ 4 | .chain(result) 5 | .map('textContent') 6 | .map(x => x.trim().split(':')[0]) 7 | .value() 8 | return results 9 | } 10 | 11 | describe('Prefixes', () => { 12 | beforeEach(() => { 13 | cy.visit('/prefixes') 14 | }) 15 | 16 | it('should list prefixes in alphabetical order', () => { 17 | cy.get('#prefixes li') 18 | .then(collectResults) 19 | .then((list) => { 20 | expect(list).to.deep.equal(_.sortBy(list)) 21 | }) 22 | }) 23 | 24 | it('should lead to a single prefix', () => { 25 | cy.get('#prefixes li').first().click() 26 | cy.url().should('include', '/prefix/') 27 | }) 28 | 29 | it('should redirect missing prefix', () => { 30 | cy.visit('/prefix/') 31 | cy.url().should('include', '/prefixes') 32 | }) 33 | 34 | it('should redirect prefixes that do not end with `:`', () => { 35 | cy.visit('/prefix/schema') 36 | cy.url().should('include', '/prefix/schema:') 37 | cy.visit('/prefix/foobarbaz', { failOnStatusCode: false }) 38 | cy.url().should('include', '/prefix/foobarbaz:') 39 | }) 40 | 41 | it('should 404 unknown prefixes', () => { 42 | cy.visit('/prefix/hahaha:', { failOnStatusCode: false }).then((res) => { 43 | cy.get('.content-container > h1').invoke('text').then((text) => { 44 | expect(text).to.equal('404') 45 | }) 46 | }) 47 | }) 48 | 49 | it('should list classes and properties of a single prefix', () => { 50 | cy.get('#prefixes li').first().click() 51 | cy.get('h1 > code').invoke('text').then((prefix) => { 52 | cy.url().should('include', `/prefix/${prefix}`) 53 | }) 54 | cy.get('#rdfs-class ul li').then((list) => { 55 | expect(list).to.have.length.of.at.least(1) 56 | }) 57 | cy.get('#rdf-property ul li').then((list) => { 58 | expect(list).to.have.length.of.at.least(1) 59 | }) 60 | }) 61 | 62 | it('should lead to individual terms', () => { 63 | cy.get('#prefixes li').first().click() 64 | cy.get('h1 > code').invoke('text').then((prefix) => { 65 | cy.get('#rdfs-class ul li').first().invoke('text').then((term) => { 66 | cy.get('#rdfs-class ul li').first().find('a').click().then(() => { 67 | cy.url().should('include', term.trim().split(' ')[0]) 68 | }) 69 | }) 70 | }) 71 | }) 72 | }) 73 | -------------------------------------------------------------------------------- /test/e2e/integration/search_spec.js: -------------------------------------------------------------------------------- 1 | /* eslint-disable cypress/no-unnecessary-waiting */ 2 | 3 | const collectResults = n => (result) => { 4 | const results = Cypress._ 5 | .chain(result) 6 | .map('textContent') 7 | .map(x => x.trim()) 8 | .value() 9 | if (n) { 10 | cy.wrap(results.slice(0, n)).snapshot() 11 | } 12 | else { 13 | cy.wrap(results).snapshot() 14 | } 15 | } 16 | 17 | const searchField = () => cy.get('.search-field-container input') 18 | const suggestionList = () => cy.get('.autocomplete .results') 19 | const suggestedElements = () => cy.get('.autocomplete .results li') 20 | const keys = { 21 | generic: x => cy.focused().trigger('keydown', { keyCode: x, which: x }), 22 | downArrow: () => keys.generic(40), 23 | upArrow: () => keys.generic(38), 24 | repeat (what, count, time = 10) { 25 | for (let i = 0; i < count; i++) { 26 | what() 27 | cy.wait(time) 28 | } 29 | } 30 | } 31 | 32 | describe('Search', () => { 33 | beforeEach(() => { 34 | cy.visit('/') 35 | searchField().focus().clear() 36 | }) 37 | 38 | it('should be available on homepage', () => { 39 | searchField().type('rdau:P608') 40 | suggestionList().should('be.visible') 41 | suggestedElements().then(collectResults()) 42 | searchField().clear() 43 | suggestionList().should('not.be.visible') 44 | 45 | searchField().type('Person') 46 | suggestionList().should('be.visible') 47 | suggestedElements().then(collectResults(6)) 48 | searchField().clear() 49 | suggestionList().should('not.be.visible') 50 | 51 | searchField().type('rdfs') 52 | suggestionList().should('be.visible') 53 | suggestedElements().then(collectResults()) 54 | searchField().clear() 55 | suggestionList().should('not.be.visible') 56 | }) 57 | 58 | it('should navigate results with keyboard', () => { 59 | searchField().type('schema:P') 60 | suggestionList().should('be.visible') 61 | keys.repeat(keys.downArrow, 6) 62 | cy.focused().should('have.attr', 'href').and('include', '/schema:') 63 | keys.repeat(keys.upArrow, 3) 64 | keys.downArrow() 65 | cy.focused().should('have.attr', 'href').and('include', '/schema:') 66 | keys.upArrow() 67 | keys.downArrow() 68 | keys.upArrow() 69 | cy.focused().should('have.attr', 'href').and('include', '/schema:') 70 | cy.focused().invoke('attr', 'href') 71 | .then((href) => { 72 | cy.focused().click() 73 | cy.url().should('equal', `http://localhost:3000${href}`) 74 | }) 75 | }) 76 | 77 | it('should navigate to a single prefix', () => { 78 | searchField().type('rdfs:') 79 | suggestionList().should('be.visible') 80 | keys.downArrow() 81 | cy.focused().click() 82 | cy.url().should('equal', 'http://localhost:3000/prefix/rdfs:') 83 | }) 84 | 85 | it('should redirect to the correct form of existing terms', () => { 86 | searchField().type('schema:persON') 87 | suggestionList().should('be.visible') 88 | cy.get('form').submit() 89 | cy.url().should('equal', 'http://localhost:3000/schema:Person') 90 | }) 91 | 92 | const searchTerms = ['schema:Lol', 'schema:', 'foo'] 93 | 94 | searchTerms.forEach((term) => { 95 | it(`should search for ${term} on submit, redirect and display suggestions`, () => { 96 | searchField().type(term) 97 | suggestionList().should('be.visible') 98 | cy.get('form').submit() 99 | suggestionList().should('be.visible') 100 | cy.url().should('equal', `http://localhost:3000/${term}`) 101 | }) 102 | }) 103 | 104 | it('should be case sensitive', () => { 105 | searchField().type('qb:Slice') 106 | cy.get('form').submit() 107 | cy.url().should('equal', 'http://localhost:3000/qb:Slice') 108 | cy.get('.main-results section').invoke('text').then((foo) => { 109 | searchField().type('qb:slice') 110 | cy.get('form').submit() 111 | cy.url().should('equal', 'http://localhost:3000/qb:slice') 112 | cy.wait(500) 113 | cy.get('.main-results section').invoke('text').then((bar) => { 114 | expect(foo).not.to.equal(bar) 115 | }) 116 | }) 117 | }) 118 | }) 119 | -------------------------------------------------------------------------------- /test/e2e/plugins/index.js: -------------------------------------------------------------------------------- 1 | const browserify = require('@cypress/browserify-preprocessor') 2 | 3 | // plugins file 4 | module.exports = (on, config) => { 5 | const options = browserify.defaultOptions 6 | // print options to find babelify, it is inside transforms at index 1 7 | // and it is [filename, options] 8 | const babelOptions = options.browserifyOptions.transform[1][1] 9 | babelOptions.global = true 10 | // ignore all modules except the ones that are ES6 11 | babelOptions.ignore = [/\/node_modules\/(?!@nuxtjs\/)/] 12 | // if you want to see the final options 13 | // console.log('%o', babelOptions) 14 | 15 | on('file:preprocessor', browserify(options)) 16 | 17 | return config 18 | } 19 | -------------------------------------------------------------------------------- /test/e2e/support/index.js: -------------------------------------------------------------------------------- 1 | require('@cypress/snapshot').register() 2 | --------------------------------------------------------------------------------