My pretty neat website
git clone git://soophie.de/soso
blob: 63524fb87fdcc6db60eedbc0ed2024cc95db352a (5184 bytes)[raw]
1
% #include "src/duc_macro.h" %2
% #include "src/module/git_repo.h" %3
% #include "src/module/git_repo_log.h" %4
% #include "src/module/git_repo_tree.h" %5
% #include "src/module/git_repo_refs.h" %6
% #include "src/module/git_repo_commit.h" %7
% #include "src/module/git_repo_blob.h" %9
% DUC_TEMPLDEF(10
duc_git_repo,11
git_repo_t repo;12
const char *tab_mode;13
) %14
% if (ctx->tab_mode && strcmp(ctx->tab_mode, "raw") == 0) {15
ORB_MODULE_DEF(GIT_REPO_BLOB_TYPE, &((git_repo_blob_param_list_t) {16
.repo = &ctx->repo,17
.is_raw = true,18
}))19
return;20
} %21
<div class="git--repo">22
<h2>% STRING(ctx->repo.meta.name) %</h2>23
<p>24
% if (ctx->repo.meta.description) { % <span class="repo--description">% STRING(ctx->repo.meta.description) %</span><br/> % } %25
<span class="repo--clone">git clone <a href="git://soophie.de/% STRING(ctx->repo.meta.name) %">git://soophie.de/% STRING(ctx->repo.meta.name) %</a></span>26
</p>27
<ul class="link-list">28
<li class="link % if (strcmp(ctx->tab_mode, "log") == 0 || strcmp(ctx->tab_mode, "commit") == 0) { %link--active% } %"><a href="/git/% STRING(ctx->repo.meta.name) if (ctx->repo.ref) { %?ref=% STRING(ctx->repo.ref->oid) } %">log</a></li>29
% bool is_readme = ctx->repo.flag_oid && ctx->repo.readme_oid && strcmp(ctx->repo.flag_oid, ctx->repo.readme_oid) == 0; %30
% bool is_license = ctx->repo.flag_oid && ctx->repo.license_oid && strcmp(ctx->repo.flag_oid, ctx->repo.license_oid) == 0; %31
<li class="link % if (strcmp(ctx->tab_mode, "tree") == 0 || (strcmp(ctx->tab_mode, "blob") == 0 && !is_readme && !is_license)) { %link--active% } %"><a href="/git/% STRING(ctx->repo.meta.name) %/tree% if (ctx->repo.ref) { %?ref=% STRING(ctx->repo.ref->oid) } %">tree</a></li>32
<li class="link % if (strcmp(ctx->tab_mode, "refs") == 0) { %link--active% } %"><a href="/git/% STRING(ctx->repo.meta.name) %/refs% if (ctx->repo.ref) { %?ref=% STRING(ctx->repo.ref->oid) } %">refs</a></li>33
% if (ctx->repo.readme_oid) { %34
<li class="link % if (strcmp(ctx->tab_mode, "blob") == 0 && is_readme) { %link--active% } %"><a href="/git/% STRING(ctx->repo.meta.name) %/blob?% if (ctx->repo.ref) { %ref=% STRING(ctx->repo.ref->oid) %&% } %oid=% STRING(ctx->repo.readme_oid) %">README</a></li>35
% } %36
% if (ctx->repo.license_oid) { %37
<li class="link % if (strcmp(ctx->tab_mode, "blob") == 0 && is_license) { %link--active% } %"><a href="/git/% STRING(ctx->repo.meta.name) %/blob?% if (ctx->repo.ref) { %ref=% STRING(ctx->repo.ref->oid) %&% } %oid=% STRING(ctx->repo.license_oid) %">LICENSE</a></li>38
% } %39
</ul>40
%41
char *tab = "";42
if (ctx->tab_mode) {43
if (strcmp(ctx->tab_mode, "log") == 0) tab = "log";44
if (strcmp(ctx->tab_mode, "commit") == 0) tab = "log";45
if (strcmp(ctx->tab_mode, "tree") == 0) tab = "tree";46
if (strcmp(ctx->tab_mode, "blob") == 0) tab = "tree";47
if (strcmp(ctx->tab_mode, "refs") == 0) tab = "refs";48
}49
bool is_branch_select = true;50
if (ctx->repo.flag_oid) {51
if (ctx->repo.readme_oid && strcmp(ctx->repo.flag_oid, ctx->repo.readme_oid) == 0) is_branch_select = false;52
if (ctx->repo.license_oid && strcmp(ctx->repo.flag_oid, ctx->repo.license_oid) == 0) is_branch_select = false;53
}54
%55
% if (is_branch_select) { %56
<select class="repo--branch" onchange="window.location.href = '/git/% STRING(ctx->repo.meta.name) %/% STRING(tab) %?ref=' + this.value">57
% for (size_t i = 0; i < ctx->repo.ref_list_len; i++) {58
git_repo_ref_t *ref = &ctx->repo.ref_list[i];59
if (!ref->name || !ref->oid) continue;60
bool is_selected = (ctx->repo.ref && strcmp(ctx->repo.ref->oid, ref->oid) == 0)61
|| (!ctx->repo.ref && ctx->repo.ref_head && strcmp(ctx->repo.ref_head->oid, ref->oid) == 0);62
%63
<option value="% STRING(ref->oid) %" % if (is_selected) { %selected% } %>64
% if (ref->type) { STRING(ref->type) %:% } STRING(ref->name) %65
</option>66
% } %67
</select>68
% } %69
<div class="repo--tab">70
% if (ctx->tab_mode && strcmp(ctx->tab_mode, "log") == 0) {71
ORB_MODULE_DEF(GIT_REPO_LOG_TYPE, &((git_repo_log_param_list_t) {72
.repo = &ctx->repo,73
}))74
} %75
% if (ctx->tab_mode && strcmp(ctx->tab_mode, "tree") == 0) {76
ORB_MODULE_DEF(GIT_REPO_TREE_TYPE, &((git_repo_tree_param_list_t) {77
.repo = &ctx->repo,78
}))79
} %80
% if (ctx->tab_mode && strcmp(ctx->tab_mode, "refs") == 0) {81
ORB_MODULE_DEF(GIT_REPO_REFS_TYPE, &((git_repo_refs_param_list_t) {82
.repo = &ctx->repo,83
}))84
} %85
% if (ctx->tab_mode && strcmp(ctx->tab_mode, "commit") == 0) {86
ORB_MODULE_DEF(GIT_REPO_COMMIT_TYPE, &((git_repo_commit_param_list_t) {87
.repo = &ctx->repo,88
}))89
} %90
% if (ctx->tab_mode && strcmp(ctx->tab_mode, "blob") == 0) {91
bool is_markdown = false;92
if (ctx->repo.flag_oid) {93
if (ctx->repo.readme_oid && strcmp(ctx->repo.flag_oid, ctx->repo.readme_oid) == 0) is_markdown = true;94
}95
ORB_MODULE_DEF(GIT_REPO_BLOB_TYPE, &((git_repo_blob_param_list_t) {96
.repo = &ctx->repo,97
.is_markdown = is_markdown,98
}))99
} %100
</div>101
</div>103
% DUC_ENDTEMPL %