ホーム 記事一覧 ブック DH週間トピックス 検索 このサイトについて
English
ZoteroのAPIをNext.jsから使う

ZoteroのAPIをNext.jsから使う

概要 ZoteroのAPIをNext.jsから使う方法を調べましたので、備忘録です。結果、以下のアプリケーションを作成しました。 https://zotero-rouge.vercel.app/ ライブラリ 以下のライブラリを使用しました。 https://github.com/tnajdek/zotero-api-client API Keyなどの取得 以下の記事を参考にしてください。 使い方 コレクション一覧 // app/api/zotero/collections/route.js import { NextResponse } from "next/server"; import api from "zotero-api-client"; import { prisma } from "@/lib/prisma"; import { decrypt } from "../../posts/encryption"; import { getSession } from "@auth0/nextjs-auth0"; async function fetchZoteroCollections( zoteroApiKey: string, zoteroUserId: string ) { const myapi = api(zoteroApiKey).library("user", zoteroUserId); const collectionsResponse = await myapi.collections().get(); return collectionsResponse.raw; } 特定のコレクション // app/api/zotero/collection/[id]/route.ts import { NextResponse } from "next/server"; import api from "zotero-api-client"; import { prisma } from "@/lib/prisma"; import { decrypt } from "@/app/api/posts/encryption"; import { getSession } from "@auth0/nextjs-auth0"; async function fetchZoteroCollection( zoteroApiKey: string, zoteroUserId: string, collectionId: string ) { const myapi = api(zoteroApiKey).library("user", zoteroUserId); const collectionResponse = await myapi.collections(collectionId).get(); return collectionResponse.raw; } 特定のコレクション内のアイテム一覧 // app/api/zotero/collection/[id]/items/route.ts import { NextResponse, NextRequest } from "next/server"; import api from "zotero-api-client"; import { prisma } from "@/lib/prisma"; import { decrypt } from "@/app/api/posts/encryption"; import { getSession } from "@auth0/nextjs-auth0"; async function fetchZoteroCollection( zoteroApiKey: string, zoteroUserId: string, collectionId: string ) { const myapi = api(zoteroApiKey).library("user", zoteroUserId); const collectionResponse = await myapi .collections(collectionId) .items() .get(); return collectionResponse.raw; 参考 アプリケーションはVercelにホスティングされており、データベースにはVercel Postgres、ORMにはPrismaを使用しました。UIはTailwind CSSで構築され、ChatGPTのデザイン提案を使用しました。また、認証にはAuth0を採用しています。 まとめ ZoteroのAPI利用にあたり、参考になりましたら幸いです。 ...

RELAX NGとSchematron

RELAX NGとSchematron

概要 oXygen XML EditorでTEI/XMLを作成すると、以下のようなテンプレートが作成されます。 <?xml version="1.0" encoding="UTF-8"?> <?xml-model href="http://www.tei-c.org/release/xml/tei/custom/schema/relaxng/tei_all.rng" type="application/xml" schematypens="http://relaxng.org/ns/structure/1.0"?> <?xml-model href="http://www.tei-c.org/release/xml/tei/custom/schema/relaxng/tei_all.rng" type="application/xml" schematypens="http://purl.oclc.org/dsdl/schematron"?> <TEI xmlns="http://www.tei-c.org/ns/1.0"> <teiHeader> <fileDesc> <titleStmt> <title>Title</title> </titleStmt> <publicationStmt> <p>Publication Information</p> </publicationStmt> <sourceDesc> <p>Information about the source</p> </sourceDesc> </fileDesc> </teiHeader> <text> <body> <p>Some text here.</p> </body> </text> </TEI> この時、以下の違いが気になりましたので、GPT4への問い合わせ結果を共有します。 <?xml-model href="http://www.tei-c.org/release/xml/tei/custom/schema/relaxng/tei_all.rng" type="application/xml" schematypens="http://relaxng.org/ns/structure/1.0"?> <?xml-model href="http://www.tei-c.org/release/xml/tei/custom/schema/relaxng/tei_all.rng" type="application/xml" schematypens="http://purl.oclc.org/dsdl/schematron"?> 回答 2行目と3行目の違いは、schematypens属性に指定されている名前空間です。以下に詳細を説明します。 2行目 <?xml-model href="http://www.tei-c.org/release/xml/tei/custom/schema/relaxng/tei_all.rng" type="application/xml" schematypens="http://relaxng.org/ns/structure/1.0"?> href : http://www.tei-c.org/release/xml/tei/custom/schema/relaxng/tei_all.rng type : application/xml schematypens : http://relaxng.org/ns/structure/1.0 この行は、TEI (Text Encoding Initiative) ドキュメントに対して RELAX NG スキーマを指定しています。RELAX NG はXML文書の構造を検証するためのスキーマ言語です。 ...

Linuxシステムで特定のグループに所属しているユーザーを確認する

Linuxシステムで特定のグループに所属しているユーザーを確認する

概要 ! ChatGPT 4による回答です。 Linuxシステムで特定のグループに所属しているユーザーを確認するには、いくつかの方法があります。ここでは、コマンドラインを使用して、特定のグループ(この場合は「group1」と「group2」)に所属するユーザーをリストする方法を説明します。 方法1: /etc/group ファイルを確認する Linuxでは、/etc/group ファイルにシステム上のすべてのグループとそれに所属するユーザーの情報が格納されています。このファイルを確認することで、特定のグループに含まれるユーザーを確認することができます。 コマンド: grep '^group1:' /etc/group grep '^group2:' /etc/group これらのコマンドは、group1 と group2 グループについての情報を /etc/group ファイルから検索し、出力します。出力例は以下のようになります: group1:x:1001:user1,user2 group2:x:1002:user3,user4 ここで、user1 と user2 は group1 グループのメンバーで、user3 と user4 は group2 グループのメンバーです。 方法2: getent コマンドを使用する getent コマンドを使用しても、グループに所属するユーザーを調べることができます。このコマンドは /etc/group ファイルから直接情報を取得します。 コマンド: getent group group1 getent group group2 出力は /etc/group を grep した時と同様のフォーマットです。 方法3: members コマンドを使用する members コマンドは、特定のグループに属するすべてのユーザーの名前をリストアップするために使われます。ただし、このコマンドはすべてのLinuxディストリビューションにはデフォルトでインストールされていないため、インストールが必要な場合があります。 コマンド: sudo apt install members # Debian系の場合 members group1 members group2 これらの方法を使用して、group1 および group2 グループに含まれるユーザーを確認できます。どの方法を選択するかは、使用しているシステムやインストールされているプログラムによります。 ...