diff --git a/CMakeLists.txt b/CMakeLists.txt index 280f4db..ed76f77 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -30,13 +30,18 @@ find_program(CPPCMS_TMPL_CC NAMES cppcms_tmpl_cc REQUIRED) # --- Generate cppcms views from the template skin ------------------------- -set(SKIN ${CMAKE_CURRENT_SOURCE_DIR}/templates/skin.tmpl) +set(TEMPLATE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/templates) +set(SKINS + ${TEMPLATE_DIR}/master.tmpl + ${TEMPLATE_DIR}/pages.tmpl + ${TEMPLATE_DIR}/repo.tmpl + ${TEMPLATE_DIR}/history.tmpl) set(VIEWS_CPP ${CMAKE_CURRENT_BINARY_DIR}/views.cpp) add_custom_command( OUTPUT ${VIEWS_CPP} - COMMAND ${CPPCMS_TMPL_CC} ${SKIN} -o ${VIEWS_CPP} - DEPENDS ${SKIN} - COMMENT "Generating cppcms views from skin.tmpl" + COMMAND ${CPPCMS_TMPL_CC} ${SKINS} -o ${VIEWS_CPP} + DEPENDS ${SKINS} + COMMENT "Generating cppcms views from templates" VERBATIM) # --- Application ---------------------------------------------------------- diff --git a/templates/history.tmpl b/templates/history.tmpl new file mode 100644 index 0000000..55f5d6f --- /dev/null +++ b/templates/history.tmpl @@ -0,0 +1,151 @@ +<% c++ #include "content.h" %> +<% c++ #include "util.h" %> +<% skin git %> + +<% view log_view uses content::log_view extends master %> +<% template content_body() %> +

log: <%= repo %>

+<% if (content.has_bodies) %> +

+<% end %> + +<% foreach c in commits %><% item %> + + + + + + +<% end item %><% empty %> + +<% end %> +
<%= c.short_oid %><%= c.summary %> +<% if (c.body.length() > 0) %> + +<% end %> +<%= c.author_name %><% c++ out() << util::format_time(c.time); %>
no commits
+<% end template %> +<% end view %> + +<% view object_view uses content::object_view extends master %> +<% template content_body() %> +

object <%= object.oid %>

+

type: <%= object.type_name %>

+<% if (content.object.kind == ObjectKind::Tree) %> + +<% foreach e in object.entries %><% item %> + + + + +<% end item %><% end foreach %> +
<%= e.name %><%= e.oid %>
+<% else %> +
<%= object.body %>
+<% end %> +<% end template %> +<% end view %> + +<% view tags_view uses content::tags_view extends master %> +<% template content_body() %> +

tags: <%= repo %>

+ +<% foreach t in tags %><% item %> + + + + + + + +<% end item %><% empty %> + +<% end %> +
<%= t.short_oid %><%= t.name %>browse filesdownload .tar.gz<% c++ out() << util::format_time(t.time); %>
no tags
+<% end template %> +<% end view %> + +<% view tag_view uses content::tag_view extends master %> +<% template content_body() %> +

tag: <%= tag.name %>

+

+<% if tag.annotated %>annotated<% else %>lightweight<% end %> · +points to <%= tag.short_oid %> +· <% c++ out() << util::format_time(content.tag.time); %> +· browse filesdownload .tar.gz +<% if (content.tag.tagger_name.length() > 0) %>
tagger: <%= tag.tagger_name %><% end %> +

+<% if (content.tag.message.length() > 0) %> +
<%= tag.message %>
+<% end %> +<% end template %> +<% end view %> + +<% view branches_view uses content::branches_view extends master %> +<% template content_body() %> +

branches: <%= repo %>

+ +<% foreach b in branches %><% item %> + + + + + + + +<% end item %><% empty %> + +<% end %> +
<%= b.short_oid %><%= b.name %><% if b.is_default %> (default)<% end %>logbrowse files<% c++ out() << util::format_time(b.time); %>
no branches
+<% end template %> +<% end view %> + +<% view commit_view uses content::commit_view extends master %> +<% template content_body() %> +

commit <%= commit.short_oid %>

+<% if (not content.on_default_branch) %> +<% if (content.branches.size() > 0) %> +

branches: <% foreach b in branches %><% item %><%= b.name %> <% end item %><% end foreach %>

+<% else %> +

not on any branch

+<% end %> +<% end %> +

+<%= commit.author_name %><% if (content.commit.author_email.length() > 0) %> <<%= commit.author_email %>><% end %> · +<% c++ out() << util::format_time(content.commit.time); %>
+<%= commit.oid %> +patchbrowse files +<% foreach p in commit.parents %><% item %>
parent <%= p %><% end item %><% end foreach %> +

+
<%= commit.message %>
+

Changed files

+ +<% foreach f in commit.files %><% item %> + + + + +<% end item %><% empty %> + +<% end %> +
<%= f.status %> +<% if (f.status == 'D') %> +<%= f.path %> +<% else %> +<%= f.path %> +<% end %> +<% if (content.commit.first_parent.length() > 0 and (f.status == 'M' or f.status == 'D')) %> +before +<% end %> +
no changes
+
+<% foreach d in commit.diff %><% item %> +
<%= d.content %>
+<% end item %><% end foreach %> +
+<% end template %> +<% end view %> + +<% end skin %> diff --git a/templates/master.tmpl b/templates/master.tmpl new file mode 100644 index 0000000..7795756 --- /dev/null +++ b/templates/master.tmpl @@ -0,0 +1,45 @@ +<% c++ #include "content.h" %> +<% c++ #include "util.h" %> +<% skin git %> + +<% view master uses content::master %> +<% template render() %> + + + + +<%= title %> · git + + + + +
+git +repos +<% if (content.repo.length() == 0) %> +about +<% end %> +<% if (content.repo.length() > 0) %> +/ +<%= repo %> + +<% end %> +
+
<% include content_body() %>
+ + + + + + + +<% end template %> +<% template content_body() %><% end template %> +<% end view %> + +<% end skin %> diff --git a/templates/pages.tmpl b/templates/pages.tmpl new file mode 100644 index 0000000..3acc3de --- /dev/null +++ b/templates/pages.tmpl @@ -0,0 +1,33 @@ +<% c++ #include "content.h" %> +<% c++ #include "util.h" %> +<% skin git %> + +<% view frontpage uses content::frontpage extends master %> +<% template content_body() %> +

Multi Git Frontend

+

Serving <%= repo_count %> repositories.

+

Browse repositories →

+<% end template %> +<% end view %> + +<% view about uses content::master extends master %> +<% template content_body() %> +

About

+

A lightweight, read-only web frontend for browsing and cloning local git repositories.

+<% end template %> +<% end view %> + +<% view repo_list uses content::repo_list extends master %> +<% template content_body() %> +

Repositories

+ +<% end template %> +<% end view %> + +<% end skin %> diff --git a/templates/repo.tmpl b/templates/repo.tmpl new file mode 100644 index 0000000..5777132 --- /dev/null +++ b/templates/repo.tmpl @@ -0,0 +1,163 @@ +<% c++ #include "content.h" %> +<% c++ #include "util.h" %> +<% skin git %> + +<% view repo_home uses content::repo_home extends master %> +<% template content_body() %> +

<%= repo %>

+

default branch: <%= default_branch %> · commit <%= commit_oid %>

+

+files · +log +

+<% if (content.clone_http.length() > 0 or content.clone_https.length() > 0) %> +
+

Checkout

+<% if (content.clone_http.length() > 0) %> +

Non-GitHub git clone <%= clone_http %>

+<% end %> +<% if (content.clone_https.length() > 0) %> +

HTTPS git clone <%= clone_https %>

+

SSH git clone <%= clone_ssh %>

+<% end %> +
+<% end %> +<% if (content.readme_name.length() > 0) %> +
Loading README…
+ +<% else %> +

No README found.

+<% end %> +<% end template %> +<% end view %> + +<% view tree_view uses content::tree_view extends master %> +<% template content_body() %> +

<%= repo %><% if (content.path.length() > 0) %>/<%= path %><% end %>

+<% if (content.query.length() > 0) %> +

browsing at commit = <%= commit_oid %>

+<% end %> +<% if (not content.on_default_branch) %> +<% if (content.branches.size() > 0) %> +

branches: <% foreach b in branches %><% item %><%= b.name %> <% end item %><% end foreach %>

+<% else %> +

not on any branch

+<% end %> +<% end %> +<% if (content.tags.size() > 0) %> +

tags: <% foreach t in tags %><% item %><%= t %> <% end item %><% end foreach %>

+<% end %> +<% if (content.entries.size() > 0) %> +

+<% end %> + +<% if (not content.is_root) %> + +<% end %> +<% foreach e in entries %><% item %> + + + + +<% end item %><% empty %> + +<% end %> +
..
+<% if e.is_dir %> +<%= e.name %>/ +<% else %> +<% if e.is_submodule %> +<%= e.name %> @ <%= e.oid %> +<% else %> +<%= e.name %> +<% end %> +<% end %> +<% if e.is_dir %><% else %><% if e.is_submodule %><% else %><% c++ out() << util::human_size(e.size); %><% end %><% end %>
empty tree
+ +<% end template %> +<% end view %> + +<% view file_view uses content::file_view extends master %> +<% template content_body() %> +

<%= path %>

+<% if (content.query.length() > 0) %> +

browsing at commit = <%= commit_oid %>

+<% end %> +<% if (not content.on_default_branch) %> +<% if (content.branches.size() > 0) %> +

branches: <% foreach b in branches %><% item %><%= b.name %> <% end item %><% end foreach %>

+<% else %> +

not on any branch

+<% end %> +<% end %> +<% if (content.tags.size() > 0) %> +

tags: <% foreach t in tags %><% item %><%= t %> <% end item %><% end foreach %>

+<% end %> +

+raw · +blame · +history +

+<% if is_image %> +

<%= filename %>

+<% if not empty text %> +
<%= text %>
+<% end %> +<% else %> +<% if is_binary %> +

Binary file (<% c++ out() << util::human_size(content.size); %>) — +view raw

+<% else %> +<% if is_markdown %> +
Loading…
+ +<% else %> +
<%= text %>
+<% end %> +<% end %> +<% end %> +<% end template %> +<% end view %> + +<% view blame_view uses content::blame_view extends master %> +<% template content_body() %> +

blame: <%= path %>

+

+normal view · +raw +

+ +<% foreach l in lines %><% item %> + + + + + + +<% end item %><% end foreach %> +
<%= l.short_oid %><%= l.author %><%= l.number %>
<%= l.content %>
+<% end template %> +<% end view %> + +<% end skin %> diff --git a/templates/skin.tmpl b/templates/skin.tmpl deleted file mode 100644 index 2454759..0000000 --- a/templates/skin.tmpl +++ /dev/null @@ -1,377 +0,0 @@ -<% c++ #include "content.h" %> -<% c++ #include "util.h" %> -<% skin git %> - -<% view master uses content::master %> -<% template render() %> - - - - -<%= title %> · git - - - - -
-git -repos -<% if (content.repo.length() == 0) %> -about -<% end %> -<% if (content.repo.length() > 0) %> -/ -<%= repo %> - -<% end %> -
-
<% include content_body() %>
- - - - - - - -<% end template %> -<% template content_body() %><% end template %> -<% end view %> - -<% view frontpage uses content::frontpage extends master %> -<% template content_body() %> -

Multi Git Frontend

-

Serving <%= repo_count %> repositories.

-

Browse repositories →

-<% end template %> -<% end view %> - -<% view about uses content::master extends master %> -<% template content_body() %> -

About

-

A lightweight, read-only web frontend for browsing and cloning local git repositories.

-<% end template %> -<% end view %> - -<% view repo_list uses content::repo_list extends master %> -<% template content_body() %> -

Repositories

- -<% end template %> -<% end view %> - -<% view repo_home uses content::repo_home extends master %> -<% template content_body() %> -

<%= repo %>

-

default branch: <%= default_branch %> · commit <%= commit_oid %>

-

-files · -log -

-<% if (content.clone_http.length() > 0 or content.clone_https.length() > 0) %> -
-

Checkout

-<% if (content.clone_http.length() > 0) %> -

Non-GitHub git clone <%= clone_http %>

-<% end %> -<% if (content.clone_https.length() > 0) %> -

HTTPS git clone <%= clone_https %>

-

SSH git clone <%= clone_ssh %>

-<% end %> -
-<% end %> -<% if (content.readme_name.length() > 0) %> -
Loading README…
- -<% else %> -

No README found.

-<% end %> -<% end template %> -<% end view %> - -<% view tree_view uses content::tree_view extends master %> -<% template content_body() %> -

<%= repo %><% if (content.path.length() > 0) %>/<%= path %><% end %>

-<% if (content.query.length() > 0) %> -

browsing at commit = <%= commit_oid %>

-<% end %> -<% if (not content.on_default_branch) %> -<% if (content.branches.size() > 0) %> -

branches: <% foreach b in branches %><% item %><%= b.name %> <% end item %><% end foreach %>

-<% else %> -

not on any branch

-<% end %> -<% end %> -<% if (content.tags.size() > 0) %> -

tags: <% foreach t in tags %><% item %><%= t %> <% end item %><% end foreach %>

-<% end %> -<% if (content.entries.size() > 0) %> -

-<% end %> - -<% if (not content.is_root) %> - -<% end %> -<% foreach e in entries %><% item %> - - - - -<% end item %><% empty %> - -<% end %> -
..
-<% if e.is_dir %> -<%= e.name %>/ -<% else %> -<% if e.is_submodule %> -<%= e.name %> @ <%= e.oid %> -<% else %> -<%= e.name %> -<% end %> -<% end %> -<% if e.is_dir %><% else %><% if e.is_submodule %><% else %><% c++ out() << util::human_size(e.size); %><% end %><% end %>
empty tree
- -<% end template %> -<% end view %> - -<% view file_view uses content::file_view extends master %> -<% template content_body() %> -

<%= path %>

-<% if (content.query.length() > 0) %> -

browsing at commit = <%= commit_oid %>

-<% end %> -<% if (not content.on_default_branch) %> -<% if (content.branches.size() > 0) %> -

branches: <% foreach b in branches %><% item %><%= b.name %> <% end item %><% end foreach %>

-<% else %> -

not on any branch

-<% end %> -<% end %> -<% if (content.tags.size() > 0) %> -

tags: <% foreach t in tags %><% item %><%= t %> <% end item %><% end foreach %>

-<% end %> -

-raw · -blame · -history -

-<% if is_image %> -

<%= filename %>

-<% if not empty text %> -
<%= text %>
-<% end %> -<% else %> -<% if is_binary %> -

Binary file (<% c++ out() << util::human_size(content.size); %>) — -view raw

-<% else %> -<% if is_markdown %> -
Loading…
- -<% else %> -
<%= text %>
-<% end %> -<% end %> -<% end %> -<% end template %> -<% end view %> - -<% view blame_view uses content::blame_view extends master %> -<% template content_body() %> -

blame: <%= path %>

-

-normal view · -raw -

- -<% foreach l in lines %><% item %> - - - - - - -<% end item %><% end foreach %> -
<%= l.short_oid %><%= l.author %><%= l.number %>
<%= l.content %>
-<% end template %> -<% end view %> - -<% view log_view uses content::log_view extends master %> -<% template content_body() %> -

log: <%= repo %>

-<% if (content.has_bodies) %> -

-<% end %> - -<% foreach c in commits %><% item %> - - - - - - -<% end item %><% empty %> - -<% end %> -
<%= c.short_oid %><%= c.summary %> -<% if (c.body.length() > 0) %> - -<% end %> -<%= c.author_name %><% c++ out() << util::format_time(c.time); %>
no commits
-<% end template %> -<% end view %> - -<% view object_view uses content::object_view extends master %> -<% template content_body() %> -

object <%= object.oid %>

-

type: <%= object.type_name %>

-<% if (content.object.kind == ObjectKind::Tree) %> - -<% foreach e in object.entries %><% item %> - - - - -<% end item %><% end foreach %> -
<%= e.name %><%= e.oid %>
-<% else %> -
<%= object.body %>
-<% end %> -<% end template %> -<% end view %> - -<% view tags_view uses content::tags_view extends master %> -<% template content_body() %> -

tags: <%= repo %>

- -<% foreach t in tags %><% item %> - - - - - - - -<% end item %><% empty %> - -<% end %> -
<%= t.short_oid %><%= t.name %>browse filesdownload .tar.gz<% c++ out() << util::format_time(t.time); %>
no tags
-<% end template %> -<% end view %> - -<% view tag_view uses content::tag_view extends master %> -<% template content_body() %> -

tag: <%= tag.name %>

-

-<% if tag.annotated %>annotated<% else %>lightweight<% end %> · -points to <%= tag.short_oid %> -· <% c++ out() << util::format_time(content.tag.time); %> -· browse filesdownload .tar.gz -<% if (content.tag.tagger_name.length() > 0) %>
tagger: <%= tag.tagger_name %><% end %> -

-<% if (content.tag.message.length() > 0) %> -
<%= tag.message %>
-<% end %> -<% end template %> -<% end view %> - -<% view branches_view uses content::branches_view extends master %> -<% template content_body() %> -

branches: <%= repo %>

- -<% foreach b in branches %><% item %> - - - - - - - -<% end item %><% empty %> - -<% end %> -
<%= b.short_oid %><%= b.name %><% if b.is_default %> (default)<% end %>logbrowse files<% c++ out() << util::format_time(b.time); %>
no branches
-<% end template %> -<% end view %> - -<% view commit_view uses content::commit_view extends master %> -<% template content_body() %> -

commit <%= commit.short_oid %>

-<% if (not content.on_default_branch) %> -<% if (content.branches.size() > 0) %> -

branches: <% foreach b in branches %><% item %><%= b.name %> <% end item %><% end foreach %>

-<% else %> -

not on any branch

-<% end %> -<% end %> -

-<%= commit.author_name %><% if (content.commit.author_email.length() > 0) %> <<%= commit.author_email %>><% end %> · -<% c++ out() << util::format_time(content.commit.time); %>
-<%= commit.oid %> -patchbrowse files -<% foreach p in commit.parents %><% item %>
parent <%= p %><% end item %><% end foreach %> -

-
<%= commit.message %>
-

Changed files

- -<% foreach f in commit.files %><% item %> - - - - -<% end item %><% empty %> - -<% end %> -
<%= f.status %> -<% if (f.status == 'D') %> -<%= f.path %> -<% else %> -<%= f.path %> -<% end %> -<% if (content.commit.first_parent.length() > 0 and (f.status == 'M' or f.status == 'D')) %> -before -<% end %> -
no changes
-
-<% foreach d in commit.diff %><% item %> -
<%= d.content %>
-<% end item %><% end foreach %> -
-<% end template %> -<% end view %> - -<% end skin %>