├── .gitignore ├── .gitattributes ├── Screenshot-Autocomplete-Multiple.png ├── extension.json ├── package.json ├── LICENCE.txt ├── README.md └── index.html /.gitignore: -------------------------------------------------------------------------------- 1 | /node_modules 2 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto -------------------------------------------------------------------------------- /Screenshot-Autocomplete-Multiple.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SandyRogers/Contentful-Tags-Autocomplete-Extension/HEAD/Screenshot-Autocomplete-Multiple.png -------------------------------------------------------------------------------- /extension.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "AutocompleteLinkedField", 3 | "name": "Autocomplete Linked Field", 4 | "srcdoc": "index.html", 5 | "fieldTypes": ["Symbol", "Symbols"] 6 | } 7 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "autocomplete-linked-field", 3 | "version": "2.0.0", 4 | "description": "Allows for the autocompletion of entries from like-named fields in Contenful UI.", 5 | "scripts": { 6 | "test": "echo \"Error: no test specified\" && exit 1", 7 | "create": "contentful-extension create --space-id $CONTENTFUL_API_SPACE", 8 | "update": "contentful-extension update --space-id $CONTENTFUL_API_SPACE --force", 9 | "dev": "contentful-extension update --space-id $CONTENTFUL_API_SPACE --force --src 'http://localhost:3030/index.html'" 10 | }, 11 | "author": "s@ndyroge.rs", 12 | "license": "MIT", 13 | "devDependencies": { 14 | "contentful-extension-cli": "^2.0.0" 15 | }, 16 | "dependencies": { 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /LICENCE.txt: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 Sandy Rogers 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Autocompleting Tags in Contentful 2 | 3 | [Contentful](https://www.contentful.com) is a content management platform. It has a concept of *Tags*, and these fall into their "content as metadata" approach. This means that *Tags* are just another type of [Short-Text Field](https://www.contentful.com/developers/docs/concepts/data-model/) you can add, as a [List](https://www.contentful.com/developers/docs/concepts/data-model/#array-fields). Contentful has a [Tag style appearance](https://www.contentful.com/developers/docs/concepts/editor-interfaces/]) choice for these. 4 | 5 | ## But they don't autocomplete! 6 | Tags are most useful when they autocomplete as you type things. This lets you keep some kind of consistency in your Tags across documents. Without autocomplete, you end up having "Spiderman" and "Spider-man" and "Spider Man" as three different Tags 😱️ 7 | 8 | *This UI extension adds a rendering option for Autocompleting tags to Contentful.* 9 | 10 | ![Screenshot of Autocompleting Tags extension](./Screenshot-Autocomplete-Multiple.png) 11 | 12 | ## Where do the tags come from? 13 | The tags are pulled from all fields which share the same name, throughout the Contentful-Space. 14 | 15 | (This can be restricted further so as to only pull from within the same content type... _Enable ln142 in index.html_) 16 | 17 | ## Installation and usage 18 | This uses Contentful's Extensions SDK. 19 | You need to have `npm` and `gulp` installed to use this, and [have the extensions SDK installed](https://github.com/contentful/ui-extensions-sdk). 20 | 21 | Clone or fork this repository. 22 | 23 | Install the dependencies needed with `npm install`. 24 | 25 | Create a _.env_ configuration file with your Contentful credentials: 26 | 27 | ```bash 28 | export SPACE_ID= 29 | export CONTENTFUL_MANAGEMENT_ACCESS_TOKEN= 30 | ``` 31 | 32 | Add the variables to your environment. 33 | 34 | ```bash 35 | source .env 36 | ``` 37 | 38 | ## Upload the extension to Contentful 39 | 40 | Create the extension in the space specified in the _.env_ file: 41 | 42 | ```bash 43 | npm run create 44 | ``` 45 | 46 | ## Local development 47 | 48 | _This doesn't work if you have web security enabled in your browser, since your localhost will be serving on HTTP. This is probably the case for you. It is possible to disable it, or just `npm run update` your code to the server every time!_ 49 | 50 | Start a local server, changing the port if needed: 51 | 52 | ```bash 53 | python -m SimpleHTTPServer 3030 54 | ``` 55 | 56 | Tell Contentful to render the widget from your local machine: 57 | 58 | ```bash 59 | npm run dev 60 | ``` 61 | 62 | ## Update the extension 63 | 64 | If you want to update the extension after your edit the code, run: 65 | 66 | ```bash 67 | npm run update 68 | ``` 69 | 70 | ## Using the extension in the Contentful web app 71 | 72 | Enable the extension in the Contentful web app for a "Short text" field (with "List" selected too) by opening the _Settings_ for a field and selecting this widget in the _appearance_ tab. -------------------------------------------------------------------------------- /index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 78 | 79 | 80 | 81 | 98 | 99 | 104 | 105 | 108 | 109 | 110 |
111 | 112 | 113 |
    114 |
115 | 116 |
117 |
    118 |
119 |
120 |
121 | 122 | 123 | 124 | 125 | 126 | 141 | 142 | 314 | 315 | 316 | 317 | --------------------------------------------------------------------------------