conta's diary

思ったこと、やったことを書いてます。 twitter: @conta_

1Passwordの入力フォームカスタムテンプレートを作成する

1Password 4.0リリースおめでとございます。
ちょっと使い勝手が良くなった!

簡単なサーバーの管理に1Passwordを使っているのだけれど、デフォルトのテンプレートがイケてない!
改造して1Passwordの入力フォームカスタムテンプレートを作成してみよう(・∀・)↑

とりあえず1Passwordのアプリ中を右クリック->Show Package Contentsで覗いてみる。
たいていの設定ファイルはそういうところに入っているのである。
怪しいフォルダ発見!
/Applications/1Password.app/Contents/Resources/CategoryTemplates/

/Applications/1Password.app/Contents/Resources/CategoryTemplates/Server.templateを覗いてみる。

{
    "uuid": "110",
    "localized": "yes",
    "hidden": "yes",
    "subtitle": "username",
    "icons": {
        "list": "type-server-list",
        "detail": "type-server-details"
    },
    "contents": [
        {
            "set": "",
            "disclosed": "yes",
            "fields": [
                {
                    "name": "url",
                    "type": "string"
                },
                {
                    "name": "username",
                    "type": "string",
                    "isUsername": "yes"
                },
                {
                    "name": "password",
                    "type": "concealed"
                }
            ]
        },
        {
            "set": "admin_console",
            "disclosed": "yes",
            "fields": [
                {
                    "name": "admin_console_url",
                    "type": "string"
                },
                {
                    "name": "admin_console_username",
                    "type": "string",
                    "isUsername": "yes"
                },
                {
                    "name": "admin_console_password",
                    "type": "concealed"
                }
            ]
        },
        {
            "set": "hosting_provider_details",
            "disclosed": "yes",
            "fields": [
                {
                    "name": "name",
                    "type": "string"
                },
                {
                    "name": "website",
                    "type": "string"
                },
                {
                    "name": "support_contact_url",
                    "type": "string"
                },
                {
                    "name": "support_contact_phone",
                    "type": "string"
                }
            ]
        }
    ]
}

ほう、変更してみよう。

/Applications/1Password.app/Contents/Resources/CategoryTemplates/Server.templateのコピーをとってから編集。。。


こんなかんじにしてみた。

{
    "uuid": "110",
    "localized": "yes",
    "hidden": "yes",
    "subtitle": "username",
    "icons": {
        "list": "type-server-list",
        "detail": "type-server-details"
    },
    "contents": [
        {
            "set": "",
            "disclosed": "yes",
            "fields": [
                {
                    "name": "IP",
                    "type": "string"
                },
                {
                    "name": "username",
                    "type": "string",
                    "isUsername": "yes"
                },
                {
                    "name": "password",
                    "type": "concealed"
                },
                {
                    "name": "port",
                    "type": "string"
                }
            ]
        },
        {
            "set": "admin_console",
            "disclosed": "yes",
            "fields": [
                {
                    "name": "username",
                    "type": "string"
                },
                {
                    "name": "password",
                    "type": "concealed",
                    "isUsername": "yes"
                },
                {
                    "name": "OS",
                    "type": "string"
                }
            ]
        }
    ]
}

書き換えたら一応ここJSONLint - The JSON Validator.でValidateして、間違いがないか確認する。

1Passwordを再起動してテンプレートから新規作成!

結果
f:id:contaconta:20131004014625p:plain

できた!

もしかするとアプリをアップデートするたびに書きなおさないといけないかもね(´・ω・`)

*補足1
なぜか一番初めの"contents": [ { "set": "",の部分に文字をセットするとset.〜になってしまう。バグなのかなんなのか。
*補足2
ServerCustom.templateというものを同じフォルダ内に作ったけど読み込んでくれないっぽい。"uuid": "110"も変えてみたけどだめ。
今あるテンプレートを改造しないとダメなのかね。


*くれぐれも自己責任でお願い致します。

*参考How to define a new wallet item in 1Password