blogit v1.2.1 Blogit.RepositoryProviders.Git View Source

This module implements the Blogit.RepositoryProvider behaviour.

It provides access to a git repository.

If the git repository is not accessible in the moment the locally checked one will be used and won’t be updated.

The URL to the git repository have to be specified using the :blogit setting :repository_url in the configuration.

For the author of a file is used the creator of the file in the git repository. For creation date is used the date of the first commit of the file and for the last update date is used the date of the last commit of the file.

The Blogit.RepositoryProvider.repository/0 implementation does git pull before returning the repository representation. The Blogit.RepositoryProvider.fetch/1 implementation uses git fetch to check for deleted, added or updated files.

Link to this section Summary

Functions

Invoked to update the data represented by the given repository to its most recent version

Checks if a file path is contained in the local version of the repository

Returns file information for the file located at the given file_path in the given repository. The result should be in the form of a map and should be structured like this:

%{
  "author" => the-file-author,
  "created_at" => the-date-the-file-was-created-in-iso-8601-format,
  "updated_at" => the-date-of-the-last-update-of-the-file-in-iso-8601-format
}

Invoked to get a list of file paths of set of files contained in the locally downloaded repository

Invoked to get the path to the locally downloaded data. If the repository is remote, it should have local copy or something like that

Invoked in order to read the contents of the file located at the given file_path

Invoked to get a representation value of the repository the provider manages. The actual data represented by this struct should be updated to its newest version first

Link to this section Functions

Invoked to update the data represented by the given repository to its most recent version.

If, for example the repository is remote, all the files in it should be downloaded so their most recent versions are accessible.

Returns the path to the changed files in the form of the tuple {:updates, list-of-paths}. These paths should be paths to deleted, updated or newly created files.

Callback implementation for Blogit.RepositoryProvider.fetch/1.

Checks if a file path is contained in the local version of the repository.

Callback implementation for Blogit.RepositoryProvider.file_in?/1.

Link to this function file_info(repository, file_path) View Source

Returns file information for the file located at the given file_path in the given repository. The result should be in the form of a map and should be structured like this:

%{
  "author" => the-file-author,
  "created_at" => the-date-the-file-was-created-in-iso-8601-format,
  "updated_at" => the-date-of-the-last-update-of-the-file-in-iso-8601-format
}

Callback implementation for Blogit.RepositoryProvider.file_info/2.

Link to this function list_files(folder \\ Settings.posts_folder()) View Source

Invoked to get a list of file paths of set of files contained in the locally downloaded repository.

Callback implementation for Blogit.RepositoryProvider.list_files/1.

Invoked to get the path to the locally downloaded data. If the repository is remote, it should have local copy or something like that.

Callback implementation for Blogit.RepositoryProvider.local_path/0.

Link to this function read_file(file_path, folder \\ "") View Source

Invoked in order to read the contents of the file located at the given file_path.

The second parameter can be a path to a folder relative to Blogit.RepositoryProvider.local_path/0 in which the given file_path should exist.

Callback implementation for Blogit.RepositoryProvider.read_file/2.

Invoked to get a representation value of the repository the provider manages. The actual data represented by this struct should be updated to its newest version first.

If for example the repository is remote, all the files in it should be downloaded so their most recent versions are accessible.

This structure can be passed to other callbacks in order to manage files in the repository.

Callback implementation for Blogit.RepositoryProvider.repository/0.