 
 module.exports =
 
+    # The data generated by minicms is just like any other content
+    # So we do like any other docpad project, we add template helpers to retrieve it
     templateData:
 
         getIndex: ->

                            else
                                return ''
                    ]
                    filters: [
                        name:   'Tag'
                        data:   ->
                                    tags = []
                                    filter = type: 'article'


    plugins:

        # This contains all the configuration of minicms, used for the admin panel of our blog
        # It allows you to define lists, forms and how to generate the final content
        minicms:

            #prefix:
            #    url:    'cms'     # Access the admin panel through '/cms' by default
            #    meta:   'cms'     # Store form data of each content into a 'cms' field by default (inside metadata)

            # Secret, required by signed cookie session
            secret: 'keyboard cat blog' 

            # Implement the logic you want for authentication
            auth: (login, password, callback) ->
                if login is 'admin' and password is 'password'
                    callback null, true
                else
                    callback "Invalid login or password.", false

            # List all the content that is managed by the plugin
            models: [
                # Example of a content that is unique and only has 1 entry
                name:   ['Configuration', 'Configuration'] # First is singular name, second is plural. Here we use the same because we never have multiple "Configurations"
                unique: true # Make this model "unique", that means there can only be 1 entry, not more, not less
                form:
                    url:    "/index" # Save configuration meta in index file
                    ext:    'html.md' # With a ".html.md" extension

                    # Set the metadata template of the file
                    # Each function that we put in the metadata will be called and the result will be used
                    # The context (this, @) contains the @docpad instance, a @slugify function and all the properties of the current model
                    meta:
                        title:      -> @title 
                        layout:     'home'
                        about:      -> @about

                    # The content follows the metadata. For this file, it is in markdown (because we are making a html.md file)
                    content:    -> @title

                    # For each model, we can create a form with several components that will allow the user to input data
                    components: [
                        # A 'title' field with a text input component (notice that we use this title field in the metadata template, above)
                        field:      'title'
                        label:      'Website Title' # The label is what will appear as field name in the form for the admin panel
                        type:       'text'
                    ,
                        # Another text input component to type the Author of the website (this one is still stored in the cms: key of the meta, but we don't really use it for now. Maybe later?)
                        field:      'author'
                        label:      'Website Author'
                        type:       'text'
                    ,
                        # An 'about' field using a plain textarea component
                        field:      'about'
                        label:      'About me'
                        type:       'textarea'
                        height:     100
                    ,
                        # We can choose a 'category' with a choice component.
                        field:      'category'
                        label:      'Category'
                        type:       'choice'
                        expanded:   true # The component will be "expanded" using html radio inputs

                        # The data: option returns an array of available categories.
                        # For this example, it is hardcoded but you can make your own logic using @docpad collections
                        data:       ->  ['Sport', 'News']
                    ,
                        # We add a 'sub-category' field that depends on the 'category' field
                        field:      'subCategory'
                        deps:       ['category'] # This field will update when the category field changes value
                        label:      'Sub-category'
                        type:       'choice'

                        # Here, we use the @category value to decide which sub-categories are available
                        # It will be called each time the field reloads
                        data:       ->
                                        if @category is 'Sport'
                                            return ['Footbal', 'Tennis', 'Handball', 'Swimming']
                                        else if @category is 'News'
                                            return ['Technology', 'Finance', 'Gossip']
                                        else # No category selected, then no sub-category available
                                            return []
                    ,
                        # Allow the user to change the blog logo by uploading an image
                        field:      'logo'
                        label:      'Website Logo'
                        type:       'file'
                        use:        'standard' # There can be multiple image profiles, here we define the one that will be displayed inside the form
                        optional:   true # We can make a field optional
                        images: # Image profiles
                            # For this field, we only make 1 profile called 'standard' that will resize the image to fit in a 220x220 rectangle.
                            standard:
                                # You can hardcode an extension (png, jpg, gif), or use the @ext value to dynamically generate the right type.
                                # Also works with animated gifs (but a bit experimental)
                                url:        -> "/logo.#{@ext}" # The url to create for the image
                                width:      220 # The maximum width of the image
                                height:     220 # The maximum height of the image
                    ,
                        # An example of rich text field 'wysiwyg' component
                        # The resulting value will be valid html
                        field:      'wysiwygExample'
                        label:      'Wysiwyg example'
                        type:       'wysiwyg'
                        height:     450 # Optional, set the height of the field inside the form
                    ,
                        # An example of 'markdown' component, so you can choose your philosophy: wysiwyg or markdown
                        field:      'markdownExample'
                        label:      'Markdown example'
                        type:       'markdown'
                        height:     450 # Optional, set the height of the field inside the form
                    ]
            ,
                # Example of a model that can have several entries.
                # We are making a blog, so we need articles!
                name:   ['Article', 'Articles'] # First is singular form, second is plural form. Note that urls inside admin panel will be generated by slugifying those names.
                list:
                    # Because this model can have several entries, we need a list page.
                    # Here is the configuration of it
                    # A list is showing several 'fields' of each entries inside a table layout
                    fields: [
                        name:   'Title' # Name of the 'field' in the table
                        value:  -> @title # The function will be called and the value will be used for display. Inside the function, you have access to all the entry's meta
                    ,
                        name:   'Image'
                        # If you want to display html that won't be escaped, use 'html' instead of 'value'
                        html:   ->
                            if @image?
                                return '<div style="height:32px"><img src="'+@image.square.url+'" style="width:32px;height:32px" alt="image" /></div>'
