Site

class crotal.site.Site(path, full=False, output=u'preview')[source]

Site is an abstraction of a Crotal site.

Example usage:

Parameters
  • path -- The root path of the site.
  • full -- Set as true to do a full build, false to do an incremental build.
  • output -- Indicating the path of the output folder.
Returns

None

generate()

Generate the site, first render the templates, then write the rendered files in the output path, then save the database json file db.json.

Returns
None
parse_single_file(file_path, event_type)

This method is used when single file change was detected during the server running.

When a single file is modified, created or deleted, the crotal server calls this function and pass the file_path and event_type into it. Then the model(e.g. Post or Page or Template) of the file will be found based on file_path and model will be called to react to the file change, and the output will be rewrite.

Parameters
  • file_path -- The path of the modified file.
  • event_type -- Type of the event, can be modified, created or deleted.
Returns

None

detect_file_type(file_path)

Decide which model the file belongs to.

Parameters
file_path -- Path of the file.
Returns
model that the file belongs to.
render()

Render the content of the site based on templates. :return: None

write()

Write the site content based on self.site_content.

Returns
None
save()

Save the database content into db.json. :return: None