django-simple-history: Djangoでモデルの編集履歴を記録する

概要 Djangoで編集履歴を残す方法を調べたので、その備忘録です。 以下のメッセージのように、デフォルトでは、管理画面を通じた編集履歴は記録されるが、それ以外の画面を通じた編集履歴は残らないようでした。 This object doesn’t have a change history. It probably wasn’t added via this admin site. django-simple-history そこで、以下のパッケージを使ってみます。 https://django-simple-history.readthedocs.io/en/latest/ 以下のクイックスタートのページを参考にすることで、問題なく利用できました。 https://django-simple-history.readthedocs.io/en/latest/quick_start.html 参考 以下のように、編集履歴に関するテーブルが追加され、編集履歴が記録されるようになりました。 また管理画面から、以下のような編集履歴を確認できるようになりました。管理画面以外の画面からの変更履歴を確認できました。 まとめ Djangoで編集履歴を残す際に参考になりましたら幸いです。

2023年7月3日 · 1 分 · Nakamura

Django Rest Framework (DRF)で部分一致フィルタを実装する

Django Rest Framework (DRF)で部分一致フィルタを実装するためには、Djangoフィルターバックエンドを使うのが一般的です。これは、django_filters モジュールを使用します。 このモジュールをまだインストールしていない場合は、以下のコマンドでインストールできます: pip install django-filter 以下は、部分一致検索を実現するための一般的な手順です: フィルタセットを定義します。以下はmodels.pyに存在するMyModelというモデルでnameフィールドを部分一致検索するためのフィルタセットです: import django_filters class MyModelFilter(django_filters.FilterSet): name = django_filters.CharFilter(lookup_expr='icontains') class Meta: model = MyModel fields = ['name',] ここで、lookup_expr=‘icontains’は、大文字小文字を区別せずに部分一致を行うための設定です。 次に、作成したフィルタセットをViewSetに適用します: from rest_framework import viewsets from django_filters.rest_framework import DjangoFilterBackend class MyModelViewSet(viewsets.ModelViewSet): queryset = MyModel.objects.all() serializer_class = MyModelSerializer filter_backends = [DjangoFilterBackend] filterset_class = MyModelFilter これで、クライアントからのリクエストにnameパラメータが含まれている場合、その値に部分一致するMyModelのインスタンスがレスポンスとして返されます。 ただし、これらのコードは例示のためのものであり、実際の使用ではモデルやフィールド名を適切に置き換える必要があります。また、セキュリティやパフォーマンスの観点から、適切なフィルタリングとバリデーションを行うことが重要です。

2023年7月3日 · 1 分 · Nakamura

bagit-pythonを試す

bagitは以下のように説明されています。 bagit is a Python library and command line utility for working with BagIt style packages. 本ライブラリを試すGoogle Colabのノートブックを作成しました。 https://colab.research.google.com/github/nakamura196/ndl_ocr/blob/main/bagit_python.ipynb bagitの利用にあたり、参考になりましたら幸いです。

2023年6月20日 · 1 分 · Nakamura

DjangoのModelFormを使用してアップロードしたファイルのパスを取得する

DjangoのModelFormを使用してアップロードしたファイルのパスを取得する機会がありましたのでメモします。 以下のモデルを想定します。 class Document(models.Model): file = models.FileField(upload_to='documents/') 上記に対して、以下のようなviewsで、パスにアクセスすることができました。 from django.shortcuts import render, redirect from .forms import DocumentForm def upload_file(request): if request.method == 'POST': form = DocumentForm(request.POST, request.FILES) if form.is_valid(): document = form.save() file_url = document.file.url # Correct field name used here full_path = document.file.path # Correct field name used here return redirect('some-view') else: form = DocumentForm() return render(request, 'upload.html', {'form': form}) 基本的なことかと思いますが、参考になりましたら幸いです。

2023年6月20日 · 1 分 · Nakamura

DjangoとAWS OpenSearchを接続する

概要 DjangoとAWS OpenSearchを接続する方法に関するメモです。以下の記事が参考になりました。 https://testdriven.io/blog/django-drf-elasticsearch/ ただし、上記の記事はElasticsearchを対象にした設定のため、OpenSearchに応じた変更が必要です。 変更点 以下のElasticsearch Setupの部分から、OpenSearchに応じた変更が必要でした。 https://testdriven.io/blog/django-drf-elasticsearch/#elasticsearch-setup 具体的には、以下の2つのライブラリが必要でした。 (env)$ pip install opensearch-py (env)$ pip install django-opensearch-dsl その後は、django_elasticsearch_dslとなっている箇所をdjango-opensearch-dslに、elasticsearch_dslをopensearchpyに書き換えることで、記事の通りに進めることができました。 例えば、以下のような形です。 # blog/documents.py from django.contrib.auth.models import User from django_opensearch_dsl import Document, fields # opensearchに変更 from django_opensearch_dsl.registries import registry # opensearchに変更 from blog.models import Category, Article @registry.register_document class UserDocument(Document): class Index: name = 'users' settings = { 'number_of_shards': 1, 'number_of_replicas': 0, } class Django: model = User fields = [ 'id', 'first_name', 'last_name', 'username', ] @registry.register_document class CategoryDocument(Document): id = fields.IntegerField() class Index: name = 'categories' settings = { 'number_of_shards': 1, 'number_of_replicas': 0, } class Django: model = Category fields = [ 'name', 'description', ] @registry.register_document class ArticleDocument(Document): author = fields.ObjectField(properties={ 'id': fields.IntegerField(), 'first_name': fields.TextField(), 'last_name': fields.TextField(), 'username': fields.TextField(), }) categories = fields.ObjectField(properties={ 'id': fields.IntegerField(), 'name': fields.TextField(), 'description': fields.TextField(), }) type = fields.TextField(attr='type_to_string') class Index: name = 'articles' settings = { 'number_of_shards': 1, 'number_of_replicas': 0, } class Django: model = Article fields = [ 'title', 'content', 'created_datetime', 'updated_datetime', ] Populate Elasticsearch Elasticsearchを対象にした上記の記事では、以下のコマンドが紹介されています。 ...

2023年6月19日 · 3 分 · Nakamura

Django REST framework で一括登録する

概要 Django REST framework で一括登録を行う方法を調べたので、その備忘録です。 以下の記事の通りに進めることで、一括登録用のエンドポイントを作成することができました。 https://qiita.com/Utena-lotus/items/c7bde7f663cfc4aabff1 Postman Postmanで以下のようなリクエストを送りました。 結果、以下のように、一括登録を行うことができました。 まとめ 参考になりましたら幸いです。

2023年6月17日 · 1 分 · Nakamura

djangoでJWTを使う(djangorestframework-simplejwt)

概要 djangoでJWTを使おうと思い、djangorestframework-jwtを使ってみました。 https://github.com/jpadilla/django-rest-framework-jwt 以下のサイトなどを参考にすすめてみました。 https://dev-yakuza.posstree.com/django/jwt/ ただし、‘rest_framework_jwt.authentication.JSONWebTokenAuthentication’を記述したところで、以下のエラーが発生しました。 ImportError: cannot import name 'smart_text' from 'django.utils.encoding' 調べたところ、以下の記事が見つかりました。 https://stackoverflow.com/questions/72102911/could-not-import-rest-framework-jwt-authentication-jsonwebtokenauthentication かわりにdjangorestframework-simplejwtを使え、とのことでした。 https://github.com/jazzband/djangorestframework-simplejwt 以下、こちらの使い方についてメモを残します。 djangorestframework-simplejwt 以下のページを参考にすることで、動作確認を行うことができました。 https://django-rest-framework-simplejwt.readthedocs.io/en/latest/getting_started.html Postman usernameとpasswordを使って、以下にpostします。 http://localhost:8000/api/token/ 結果、refreshとaccessが得られます。 このaccessのほうの値を使用して、HeaderにAuthorizationを設定して送ります。Bearer [jwt]の形式で送ることで、apiを利用できました。 まとめ djangoでJWTを使う際の参考になりましたら幸いです。

2023年6月17日 · 1 分 · Nakamura

DrupalのJSON:APIにおけるcorsエラーへの対応

概要 DrupalのJSON:APIによる出力結果を別のアプリから利用した際、corsエラーが発生しました。ここでは、corsエラーの改善方法について説明します。 対応 以下のファイルをコピーします。 /web/sites/default/default.services.yml cp /web/sites/default/default.services.yml /web/sites/default/services.yml そして、cors.configのenabledをtrueにします。 # Configure Cross-Site HTTP requests (CORS). # Read https://developer.mozilla.org/en-US/docs/Web/HTTP/Access_control_CORS # for more information about the topic in general. # Note: By default the configuration is disabled. cors.config: enabled: false # ここ! # Specify allowed headers, like 'x-allowed-header'. allowedHeaders: [] この結果、corsエラーを解消することができました。 まとめ 同様のことでお困りの方の参考になりましたら幸いです。

2023年6月12日 · 1 分 · Nakamura

JSON:API関連のエラーへの対処方法

概要 JSON:API関連の以下のエラーが発生しました。このエラーに対する対処方法の備忘録です。 サイトに予期せぬエラーが起こりました。しばらくたってから再度お試しください。 TypeError: Drupal\jsonapi_search_api_facets\Plugin\facets\facet_source\JsonApiFacets::__construct(): Argument #6 ($index) must be of type Drupal\search_api\IndexInterface, null given, called in /home/j-soken/drupal/web/modules/contrib/jsonapi_search_api/modules/jsonapi_search_api_facets/src/Plugin/facets/facet_source/JsonApiFacets.php on line 61 in Drupal\jsonapi_search_api_facets\Plugin\facets\facet_source\JsonApiFacets->__construct() (line 48 of modules/contrib/jsonapi_search_api/modules/jsonapi_search_api_facets/src/Plugin/facets/facet_source/JsonApiFacets.php). Drupal\jsonapi_search_api_facets\Plugin\facets\facet_source\JsonApiFacets::create() (Line: 21) Drupal\Core\Plugin\Factory\ContainerFactory->createInstance() (Line: 83) Drupal\Component\Plugin\PluginManagerBase->createInstance() (Line: 251) facets_system_breadcrumb_alter() (Line: 545) Drupal\Core\Extension\ModuleHandler->alter() (Line: 94) Drupal\Core\Breadcrumb\BreadcrumbManager->build() (Line: 72) Drupal\system\Plugin\Block\SystemBreadcrumbBlock->build() (Line: 171) Drupal\block\BlockViewBuilder::preRender() call_user_func_array() (Line: 101) ... 対処方法 まず、エラーの表示を有効にします。以下のファイルに追記します。 $config['system.logging']['error_level'] = 'verbose'; jsonapi関連で使用していたモジュールをdrushでアンインストールし、再度インストールすることで解決しました。 drush pm:uninstall drupal/search_api drupal/facets drupal/jsonapi_search_api drupal/jsonapi_search_api_facets なお、上記をさくらのレンタルサーバで実行するにあたり、drushのインストールが必要でした。以下のページを参考に、インストールしました。 https://www.drush.org/12.0.1/install/ composer require drush/drush vendor/bin/drush pm:uninstall drupal/search_api drupal/facets drupal/jsonapi_search_api drupal/jsonapi_search_api_facets その後、以下のコマンドにより、再度インストールしました。 ...

2023年6月12日 · 1 分 · Nakamura

DrupalのJSON:APIの使用方法(includeと多言語対応)

概要 DrupalのJSON:APIの使用方法に関する備忘録です。今回は、タクソノミーなどに対するincludeと多言語処理について記載します。 データ 以下のように、positionフィールドにタクソノミー「助教」を付与しています。 /node/5 また、コンテンツの多言語化を有効にしており、以下のように、タイトルとpositionの英語も表示されます。 /en/node/5 JSON:API 上記のコンテンツをコンテンツタイプ「faculty」に作成したので、以下のURLから、データの一覧を取得できます。 /jsonapi/node/faculty/ 以下は、linksフィールドを除く結果を表示しています。field_positionにタクソノミーのIDが含まれていますが、当該タクソノミーのラベル等はふくまれていません。 { "jsonapi": { "version": "1.0", "meta": { "links": { "self": { "href": "http://jsonapi.org/format/1.0/" } } } }, "data": [ { "type": "node--faculty", "id": "586ef1d9-b680-41f9-b54b-7ebcdc9d154f", "attributes": { "drupal_internal__nid": 5, "drupal_internal__vid": 13, "langcode": "ja", "revision_timestamp": "2023-06-08T01:01:43+00:00", "revision_log": null, "status": true, "title": "中村覚", "created": "2023-06-08T00:44:15+00:00", "changed": "2023-06-08T01:01:26+00:00", "promote": true, "sticky": false, "default_langcode": true, "revision_translation_affected": null, "content_translation_source": "und", "content_translation_outdated": false, "path": { "alias": null, "pid": null, "langcode": "ja" }, "body": null }, "relationships": { "node_type": { "data": { "type": "node_type--node_type", "id": "841962f7-91c8-47a1-b335-ea494efe467c", "meta": { "drupal_internal__target_id": "faculty" } } }, "revision_uid": { "data": { "type": "user--user", "id": "0b001e4d-ed29-4a53-960d-9cdcc3d3ad70", "meta": { "drupal_internal__target_id": 1 } } }, "uid": { "data": { "type": "user--user", "id": "0b001e4d-ed29-4a53-960d-9cdcc3d3ad70", "meta": { "drupal_internal__target_id": 1 } } }, "field_position": { "data": { "type": "taxonomy_term--position", "id": "6ce458e8-6d79-4ed1-9653-5ec178568b7a", "meta": { "drupal_internal__target_id": 5 } } } } } ] } includeを使う クエリに、?include=field_positionを追加します。結果、以下のように、includedフィールドが追加され、タクソノミータームのnameフィールドの値も得ることができました。 ...

2023年6月9日 · 3 分 · Nakamura

Drupal Key authを用いたコンテンツの登録と多言語対応

概要 以下の記事で、Basic認証を使ったPythonによるコンテンツ登録を行いました。 今回は、以下の記事を参考に、API Key Authenticationを試しました。 https://designkojo.com/post-drupal-using-jsonapi-vuejs-front-end API Key Authentication 以下のモジュールを使用しました。 https://www.drupal.org/project/key_auth ユーザの編集画面に「Key authentication」というタブが表示され、APIキーを生成できました。 APIキーを使用する場合には、以下のようなプログラムで実行することができました。 import requests endpoint = 'http://{ipアドレス or ドメイン名}/jsonapi/node/article' key = '{APIキー}' headers = { 'Accept': 'application/vnd.api+json', 'Content-Type': 'application/vnd.api+json', "api-key": key } payload = { "data": { "type": "node--article", "attributes": { "title": "What's up from Python", "body": { "value": "Be water. My friends.", "format": "plain_text" } } } } r = requests.post(endpoint, headers=headers, json=payload) r.json() 多言語対応における注意点 注意点として、翻訳データの作成はできないようでした。 https://www.drupal.org/docs/core-modules-and-themes/core-modules/jsonapi-module/translations 作成済みの翻訳データの更新は可能ですが、翻訳データがないノードに対しては、以下のエラーが発生しました。 { "jsonapi": { "version": "1.0", "meta": { "links": { "self": { "href": "http://jsonapi.org/format/1.0/" } } } }, "errors": [ { "title": "Method Not Allowed", "status": "405", "detail": "The requested translation of the resource object does not exist, instead modify one of the translations that do exist: ja." } ] } この点について、既に対応策ができているかもしれません。引き続き調査したいと思います。 ...

2023年6月9日 · 1 分 · Nakamura

Wagtailを試す

概要 Wagtailを試してみましたので、躓いた点などの備忘録です。 基本的には、以下のチュートリアルを参考に進めました。 https://docs.wagtail.org/en/v5.0.1/getting_started/tutorial.html 検索機能 「はじめての記事」という日本語のタイトルを持つページを追加した際、以下ではヒットしませんでした。 http://localhost:8000/admin/pages/search/?q=はじめて 一方、以下ではヒットしました。日本語の部分一致検索はデフォルトではできないようでした。 http://localhost:8000/admin/pages/search/?q=はじめての記事 Wagtail API APIについては、以下に記載がありました。 https://docs.wagtail.org/en/v5.0.1/advanced_topics/api/index.html 上記のサイトを参考に、rest_frameworkも追加することで、以下のように結果を得ることができました。 ただし、localhost:8000で立ち上げているアプリに対して、得られる結果のホスト名がlocalhostになっていました。 この点については、以下の記事を参考に、管理画面から修正できました。 https://stackoverflow.com/questions/52540254/edit-approved-email-points-to-localhost 具体的には、以下の/admin/sites/のページで、ポート番号を変更しました。 ?searchパラメータ 先の検索機能と同様、日本語については完全一致が必要なようでした。 http://localhost:8000/api/v2/pages/?search=はじめての記事 Elasticsearch Elasticsearchとの連携を試みました。 https://docs.wagtail.org/en/v5.0.1/topics/search/backends.html 今回はawsのopensearchを試してみましたが、以下のようなエラーが出てしまいました。 elasticsearch.exceptions.UnsupportedProductError: The client noticed that the server is not Elasticsearch and we do not support this unknown product 以下で同様のissueが上がっていましたが、現時点ではまだ未対応のようでした。 https://github.com/wagtail/wagtail/issues/7920 まとめ 誤った内容も含まれているかもしれませんが、Wagtailの利用にあたり、参考になりましたら幸いです。

2023年6月9日 · 1 分 · Nakamura

ArchivematicaでBrowseがうまくできない場合の原因と対応

概要 ArchivematicaでBrowseを押してもフォルダやファイルが閲覧できない不具合に遭遇しました。この原因と対策について紹介します。 /transfer/ 事象 /administration/storage/ Error retrieving locations: is the storage server running? Please contact an administrator. 以下にアクセスすると、以下のjsonが得られました。 /transfer/locations/ { "message": "Error retrieving source directories", "status": "Failure" } 対応 以下にアクセスすると、Storage Seviceにアクセスできないことが示されていました。 /administration/general/ Storage Sevice URLを修正した結果、エラーが解消しました。 まとめ 同様の事象でお困りの方の参考になりましたら幸いです。

2023年6月7日 · 1 分 · Nakamura

Amazon ECRのリポジトリを一括削除する

概要 Amazon ECRのリポジトリを一括削除する機会がありましたので、その備忘録です。ご利用される際は注意して実行してください。 リポジトリの一覧を作成 以下の記事を参考にしました。 https://qiita.com/fk_2000/items/bffd3b1ad6f3ab109766 以下を実行します。 aws ecr describe-repositories --output json | jq -re ".repositories[].repositoryName" > repository.list macの場合でjqコマンドがない場合、brew install jqなどを実行してください。 削除 以下を実行します。--forceを使って、imageがあっても削除を行います。 for X in `awk '{print $1}' repository.list` ; do aws ecr delete-repository --repository-name $X --force ; done まとめ ご利用される際は十分注意の上、実行してください。参考になりましたら幸いです。

2023年6月6日 · 1 分 · Nakamura

Django REST framework JSON:API(DJA)に独自のモデルのビューをカスタマイズする

概要 以下の記事で追加したモデルのビューをカスタマイズしてみます。 sort ordering_fieldsを追加してみます。 ... class UserInfoViewset(ModelViewSet): ordering_fields = ("user_name", ) # ここを追加 queryset = UserInfo.objects.all() serializer_class = UserInfoSerializer def get_object(self): entry_pk = self.kwargs.get("entry_pk", None) if entry_pk is not None: return Entry.objects.get(id=entry_pk).blog return super().get_object() ... 結果、「Filters」の表示で、user_nameのみが選択できるようになりました。 例えば、ageでソートを行うと、validation errorが返却されました。 フィルタ ... class UserInfoViewset(ModelViewSet): queryset = UserInfo.objects.all() serializer_class = UserInfoSerializer ordering_fields = ("user_name", ) # ここから下を追加 # override the default filter backends in order to test QueryParameterValidationFilter # without breaking older usage of non-standard query params like `page_size`. filter_backends = ( QueryParameterValidationFilter, OrderingFilter, DjangoFilterBackend, SearchFilter, ) rels = ( "exact", "iexact", "contains", "icontains", "gt", "gte", "lt", "lte", "in", "regex", "isnull", ) filterset_fields = { "id": ("exact", "in"), "user_name": rels } search_fields = ("user_name", ) ... ... 上記により、以下のようなフィルタが可能になりました。 ...

2023年6月5日 · 1 分 · Nakamura

Django REST framework JSON:API(DJA)に独自のモデルを追加する

概要 以下の記事で、Django REST framework JSON:API(DJA)の基本的な操作方法を確認しました。 本記事では、DJAに独自のモデルを追加してみます。 参考 以下の記事を参考に、UserInfoモデルを追加してみます。 https://tech-blog.rakus.co.jp/entry/20220329/python 手順 モデルを定義 以下を追記します。 # ユーザ情報を格納する class UserInfo(BaseModel): user_name = models.CharField(verbose_name='ユーザ名',max_length=32) # ユーザ名 birth_day = models.DateField(verbose_name='生年月日') # 生年月日 age = models.PositiveSmallIntegerField(verbose_name='年齢',null=True,unique=False) # 年齢 created_at = models.DateTimeField(verbose_name='作成日時',auto_now_add=True) データベースを構築 以下を実行します。 % django-admin makemigrations --settings=example.settings Migrations for 'example': example/migrations/0013_userinfo.py - Create model UserInfo % django-admin migrate --settings=example.settings Operations to perform: Apply all migrations: auth, contenttypes, example, sessions, sites Running migrations: Applying example.0013_userinfo... OK 参考までに、以下のようなファイルが作成されます。 # Generated by Django 4.1.8 on 2023-06-04 17:35 from django.db import migrations, models class Migration(migrations.Migration): dependencies = [ ("example", "0012_author_full_name"), ] operations = [ migrations.CreateModel( name="UserInfo", fields=[ ( "id", models.AutoField( auto_created=True, primary_key=True, serialize=False, verbose_name="ID", ), ), ("modified_at", models.DateTimeField(auto_now=True)), ("user_name", models.CharField(max_length=32, verbose_name="ユーザ名")), ("birth_day", models.DateField(verbose_name="生年月日")), ("age", models.PositiveSmallIntegerField(null=True, verbose_name="年齢")), ( "created_at", models.DateTimeField(auto_now_add=True, verbose_name="作成日時"), ), ], options={ "abstract": False, }, ), ] コンポーネントの作成 Serializer 以下を追記します。 ...

2023年6月5日 · 2 分 · Nakamura

Django REST framework JSON:API(DJA)を試す

概要 Django REST framework JSON:API(DJA)を試す機会がありましたので、その備忘録です。 https://django-rest-framework-json-api.readthedocs.io/en/stable/index.html インストール 以下のページに記載があるexample appを起動します。 https://django-rest-framework-json-api.readthedocs.io/en/stable/getting-started.html git clone https://github.com/django-json-api/django-rest-framework-json-api.git cd django-rest-framework-json-api python3 -m venv env source env/bin/activate pip install -Ur requirements.txt django-admin migrate --settings=example.settings django-admin loaddata drf_example --settings=example.settings django-admin runserver --settings=example.settings 結果、以下の画面などが得られました。 http://localhost:8000 for the list of available collections (in a non-JSON:API format!), http://localhost:8000/swagger-ui/ for a Swagger user interface to the dynamic schema view, or http://localhost:8000/openapi for the schema view’s OpenAPI specification document. ...

2023年6月5日 · 1 分 · Nakamura

OpenAPIとAWS CDKを用いてREST APIを作成する(Opensearch接続・カスタムドメイン)

概要 OpenAPIとAWS CDKを用いてREST APIを作成する機会がありましたので、その備忘録です。以下の記事がとても参考になりました。 https://zenn.dev/taroman_zenn/articles/91879cec40627c 今回作成したものは以下のリポジトリで公開しています。 https://github.com/nakamura196/CdkOpenapi Opensearchとの接続 以下のLambdaで実装しています。 https://github.com/nakamura196/CdkOpenapi/blob/main/lambda/search.ts Lambdaに環境変数を渡す必要があり、lib以下のtsファイルで以下のように記述しました。 ... const searchFn = new NodejsFunction(this, "search", { entry: path.join(__dirname, "../lambda/search.ts"), runtime: Runtime.NODEJS_18_X, handler: "handler", environment: { ELASTIC_HOST: process.env.ELASTIC_HOST || "", ELASTIC_USERNAME: process.env.ELASTIC_USERNAME || "", ELASTIC_PASSWORD: process.env.ELASTIC_PASSWORD || "", ELASTIC_INDEX_NAME: process.env.ELASTIC_INDEX_NAME || "", }, }); ... カスタムドメイン 以下のファイルを参考にしてください。間違いなどがあるかもしれませんが、カスタムドメインの登録からAPI Gatewayへの設定も行ってみました。 https://github.com/nakamura196/CdkOpenapi/blob/main/lib/cdk-openapi-stack.ts まとめ 色々と中途半端なリポジトリではありますが、参考になる部分があれば幸いです。

2023年5月26日 · 1 分 · Nakamura

GitHubのGUIを使ったファイルアップロードおよびファイル更新の方法について

概要 GitHubファイルアップロードおよびファイル更新の方法について共有する機会がありました。 ログイン アカウントの新規作成を含めて、以下の記事などを参考にしてください。 https://reffect.co.jp/html/create_github_account_first_time ファイルアップロード リポジトリにアクセスします。 Add fileボタンをクリックして、Upload filesをクリックします。 choose your filesをクリックして、ローカルからファイルをアップロードして、Commit changesを押します。 ファイルがアップロードされます。同じ名前のファイルが既に存在する場合には、上書き更新されます。 ファイルの更新 更新対象のファイル名をクリックします。 鉛筆アイコンをクリックします。 テキストを修正し、Commit changesボタンを押します。 再度、Commit changesボタンを押します。 ファイルが更新されます。 まとめ GitHubのGUIの使い方の参考になりましたら幸いです。

2023年5月25日 · 1 分 · Nakamura

Omeka SのImage Serverの設定について

概要 Omeka SのImage Serverは、IIIF Image APIに対応した画像配信を可能とするモジュールです。 https://omeka.org/s/modules/ImageServer/ IIIF Serverモジュールと組み合わせて使用することにより、IIIFマニフェストによる配信も可能になります。 Image Serverモジュールでは、タイル画像の作成方法を含めて、さまざまな設定が可能です。本記事では、これらの設定について、調査結果を共有します。 実験環境 今回は、Amazon LightsailのLAMPインスタンスを使用します。2 GB RAM, 1 vCPUの比較的低スペックな環境を用います。 Amazon Lightsailを用いたOmeka Sの構築方法は、以下などを参考にしてください。 また、今回は以下のスクリプトを利用しました。今回検証する「Image Server」モジュールの使用に必要な、関連モジュールを合わせてインストールします。 https://github.com/nakamura196/omeka_aws/blob/main/2023-05-25.sh タイル画像の作成に関する設定 ImageServerモジュールのインストール後、以下にアクセスすると、ImageServerの設定画面にアクセスできます。 /admin/module/configure?id=ImageServer 以下の画面の「Tiling service」の箇所で設定を行うことができます。 Image processor項目 本モジュールの説明ページでは、vipsのインストールが推奨されていました。上記のスクリプトでも、以下によって、vipsをインストールしています。 sudo apt install --no-install-recommends libvips-tools そのため、上記設定画面の「Image processor」項目の初期値に基づき、タイル画像の作成には、以後vipsが使用されます。 Tilling type項目 この項目では、「Deep Zoom Image」「Zoomify」「Jpeg 2000」「Tiled tiff」の4つの項目を選択することができます。これらについて、公式サイトでは以下のように記載されています。 Four format are proposed to create tiles: DeepZoom, Zoomify, Jpeg 2000 and pyramidal Tiff. The recommended format is DeepZoom. For Jpeg 2000 and pyramidal tiff, some other tools may be required. ...

2023年5月25日 · 2 分 · Nakamura