|
30 | 30 | <string>NSApplication</string> |
31 | 31 | <key>MainModule</key> |
32 | 32 | <string>{{ cookiecutter.module_name }}</string> |
33 | | - {% if cookiecutter.document_types %} |
| 33 | + {% if cookiecutter.document_types -%} |
34 | 34 | <key>CFBundleDocumentTypes</key> |
35 | 35 | <array> |
36 | | - {% for extension, doctype in cookiecutter.document_types.items() %} |
| 36 | + {% for document_type_id, document_type in cookiecutter.document_types.items() -%} |
| 37 | + {% set macOS = document_type.macOS | default({}) -%} |
37 | 38 | <dict> |
38 | 39 | <key>CFBundleTypeName</key> |
39 | | - <string>{{ doctype.description }}</string> |
| 40 | + <string>{{ document_type.description }}</string> |
40 | 41 | <key>CFBundleTypeIconFile</key> |
41 | | - <string>{{ cookiecutter.app_name }}-{{ extension }}.icns</string> |
42 | | - <key>CFBundleTypeExtensions</key> |
43 | | - <array> |
44 | | - <string>{{ extension }}</string> |
45 | | - </array> |
46 | | - <key>CFBundleTypeMIMETypes</key> |
47 | | - <array/> |
| 42 | + <string>{{ cookiecutter.app_name }}-{{ document_type_id }}.icns</string> |
48 | 43 | <key>CFBundleTypeRole</key> |
49 | | - <string>Viewer</string> |
| 44 | + <string>{{ macOS.CFBundleTypeRole }}</string> |
| 45 | + <key>LSHandlerRank</key> |
| 46 | + <string>{{ macOS.LSHandlerRank }}</string> |
50 | 47 | <key>LSItemContentTypes</key> |
51 | 48 | <array> |
52 | | - <string>{{ cookiecutter.bundle }}.{{ cookiecutter.app_name }}.{{ extension }}</string> |
| 49 | + {%- if macOS.LSItemContentTypes is defined %} |
| 50 | + <string>{{ macOS.LSItemContentTypes[0] }}</string> |
| 51 | + {%- else %} |
| 52 | + <string>{{ cookiecutter.bundle }}.{{ cookiecutter.app_name }}.{{ document_type_id }}</string> |
| 53 | + {%- endif %} |
53 | 54 | </array> |
54 | | - <key>LSTypeIsPackage</key> |
55 | | - <integer>1</integer> |
56 | 55 | </dict> |
57 | 56 | {% endfor %} |
58 | 57 | </array> |
59 | | - <key>UTExportedTypeDeclarations</key> |
60 | | - <array> |
61 | | - {% for doctype_id, doctype in cookiecutter.document_types.items() %} |
| 58 | + {%- macro type_declaration(cookiecutter, document_type_id, document_type, macOS) -%} |
62 | 59 | <dict> |
63 | | - <key>UTTypeIdentifier</key> |
64 | | - <string>{{ cookiecutter.bundle }}.{{ cookiecutter.app_name }}.{{ doctype_id }}</string> |
65 | | - <key>UTTypeReferenceURL</key> |
66 | | - <string>{{ doctype.url }}</string> |
67 | | - <key>UTTypeIconFile</key> |
68 | | - <string>{{ cookiecutter.app_name }}-{{ doctype_id }}.icns</string> |
69 | 60 | <key>UTTypeConformsTo</key> |
70 | 61 | <array> |
71 | | - <string>com.apple.package</string> |
| 62 | + {%- for type in macOS.UTTypeConformsTo %} |
| 63 | + <string>{{ type }}</string> |
| 64 | + {%- endfor %} |
72 | 65 | </array> |
73 | 66 | <key>UTTypeDescription</key> |
74 | | - <string>{{ doctype.description }}</string> |
| 67 | + <string>{{ document_type.description }}</string> |
| 68 | + <key>UTTypeIconFile</key> |
| 69 | + <string>{{ cookiecutter.app_name }}-{{ document_type_id }}.icns</string> |
| 70 | + <key>UTTypeIdentifier</key> |
| 71 | + {% if macOS.LSItemContentTypes is defined -%} |
| 72 | + <string>{{ macOS.LSItemContentTypes[0] }}</string> |
| 73 | + {%- else -%} |
| 74 | + <string>{{ cookiecutter.bundle }}.{{ cookiecutter.app_name }}.{{ document_type_id }}</string> |
| 75 | + {%- endif %} |
| 76 | + <key>UTTypeReferenceURL</key> |
| 77 | + <string>{{ document_type.url }}</string> |
75 | 78 | <key>UTTypeTagSpecification</key> |
76 | 79 | <dict> |
77 | 80 | <key>public.filename-extension</key> |
78 | 81 | <array> |
79 | | - <string>{{ doctype.extension }}</string> |
| 82 | + <string>{{ document_type.extension }}</string> |
80 | 83 | </array> |
| 84 | + <key>public.mime-type</key> |
| 85 | + <string>{% if document_type.get('mime_type') %}{{ document_type.mime_type }}{% else %}application/x-{{ cookiecutter.app_name }}-{{ document_type_id }}{% endif %}</string> |
81 | 86 | </dict> |
82 | 87 | </dict> |
83 | | - {% endfor %} |
| 88 | + {% endmacro %} |
| 89 | + <key>UTExportedTypeDeclarations</key> |
| 90 | + <array> |
| 91 | + {% for document_type_id, document_type in cookiecutter.document_types.items() -%} |
| 92 | + {% set macOS = document_type.macOS | default({}) -%} |
| 93 | + {% if macOS.LSHandlerRank == "Owner" -%} |
| 94 | + {{ type_declaration(cookiecutter, document_type_id, document_type, macOS) }} |
| 95 | + {%- endif %} |
| 96 | + {%- endfor %} |
| 97 | + </array> |
| 98 | + <key>UTImportedTypeDeclarations</key> |
| 99 | + <array> |
| 100 | + {% for document_type_id, document_type in cookiecutter.document_types.items() -%} |
| 101 | + {% set macOS = document_type.macOS | default({}) -%} |
| 102 | + {% if macOS.is_core_type is false and macOS.LSHandlerRank != "Owner" -%} |
| 103 | + {{ type_declaration(cookiecutter, document_type_id, document_type, macOS) }} |
| 104 | + {%- endif %} |
| 105 | + {%- endfor %} |
84 | 106 | </array> |
85 | | - {% endif %} |
| 107 | + {%- endif -%} |
86 | 108 | {%- if cookiecutter.info -%} |
87 | 109 | {%- for permission, value in cookiecutter.info.items() %} |
88 | 110 | <key>{{ permission }}</key> |
|
0 commit comments