add option to link directly to readme
This commit is contained in:
+11
@@ -54,6 +54,16 @@
|
|||||||
# file.
|
# file.
|
||||||
#recursive_repo_dirs = []
|
#recursive_repo_dirs = []
|
||||||
|
|
||||||
|
# List of files potentially containing repository documentation.
|
||||||
|
#
|
||||||
|
# Each repository root is searched for these files, in order. The
|
||||||
|
# first matching file is provided to the templates as a `readme`
|
||||||
|
# variable, with the file contents. Markdown files are rendered as
|
||||||
|
# HTML if the feature is enabled.
|
||||||
|
#
|
||||||
|
# This can also be set per-repository.
|
||||||
|
#readme_files = ["README.md", "README"]
|
||||||
|
|
||||||
# List of files to copy to the site's `global_assets` directory.
|
# List of files to copy to the site's `global_assets` directory.
|
||||||
#
|
#
|
||||||
# The files in this list are copied unmodified, and with the same name, to the
|
# The files in this list are copied unmodified, and with the same name, to the
|
||||||
@@ -535,6 +545,7 @@ generated_by = "Itsy-Gitsy"
|
|||||||
#limit_context = 200
|
#limit_context = 200
|
||||||
#limit_diffs = 200
|
#limit_diffs = 200
|
||||||
#asset_files = ["LICENSE"]
|
#asset_files = ["LICENSE"]
|
||||||
|
#readme_files = ["README.md", "README"]
|
||||||
|
|
||||||
# An alternative way to specify the user-defined attributes.
|
# An alternative way to specify the user-defined attributes.
|
||||||
#
|
#
|
||||||
|
|||||||
@@ -345,6 +345,18 @@ impl GitsyGenerator {
|
|||||||
local_ctx.insert("site_generated_ts", &generated_dt.timestamp());
|
local_ctx.insert("site_generated_ts", &generated_dt.timestamp());
|
||||||
local_ctx.insert("site_generated_offset", &generated_dt.offset().local_minus_utc());
|
local_ctx.insert("site_generated_offset", &generated_dt.offset().local_minus_utc());
|
||||||
|
|
||||||
|
if let Some(readmes) = &repo_desc.readme_files {
|
||||||
|
for readme in readmes {
|
||||||
|
if let Some(file) = parsed_repo.root_files.iter().filter(|x| &x.name == readme).next() {
|
||||||
|
louder!(" - found readme file: {}", file.name);
|
||||||
|
let _ = GitsyGenerator::fill_file_contents(&repo, &file, &repo_desc)
|
||||||
|
.expect("Failed to parse file.");
|
||||||
|
local_ctx.insert("readme", &file);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
if let Some(templ_file) = self.settings.templates.repo_summary.as_deref() {
|
if let Some(templ_file) = self.settings.templates.repo_summary.as_deref() {
|
||||||
match tera.render(templ_file, &local_ctx) {
|
match tera.render(templ_file, &local_ctx) {
|
||||||
Ok(rendered) => {
|
Ok(rendered) => {
|
||||||
|
|||||||
@@ -231,6 +231,7 @@ pub struct GitsySettingsRepo {
|
|||||||
pub clone_url: Option<String>,
|
pub clone_url: Option<String>,
|
||||||
pub website: Option<String>,
|
pub website: Option<String>,
|
||||||
pub branch: Option<String>,
|
pub branch: Option<String>,
|
||||||
|
pub readme_files: Option<Vec<String>>,
|
||||||
pub asset_files: Option<Vec<String>>,
|
pub asset_files: Option<Vec<String>>,
|
||||||
pub render_markdown: Option<bool>,
|
pub render_markdown: Option<bool>,
|
||||||
pub syntax_highlight: Option<bool>,
|
pub syntax_highlight: Option<bool>,
|
||||||
@@ -273,6 +274,7 @@ pub struct GitsySettings {
|
|||||||
pub site_url: Option<String>,
|
pub site_url: Option<String>,
|
||||||
pub site_description: Option<String>,
|
pub site_description: Option<String>,
|
||||||
pub clone_url: Option<String>,
|
pub clone_url: Option<String>,
|
||||||
|
pub readme_files: Option<Vec<String>>,
|
||||||
pub asset_files: Option<Vec<String>>,
|
pub asset_files: Option<Vec<String>>,
|
||||||
pub branch: Option<String>,
|
pub branch: Option<String>,
|
||||||
#[serde(rename(deserialize = "gitsy_templates"))]
|
#[serde(rename(deserialize = "gitsy_templates"))]
|
||||||
@@ -356,6 +358,7 @@ impl GitsySettings {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
global_to_repo!(settings, repo, branch);
|
global_to_repo!(settings, repo, branch);
|
||||||
|
global_to_repo!(settings, repo, readme_files);
|
||||||
global_to_repo!(settings, repo, render_markdown);
|
global_to_repo!(settings, repo, render_markdown);
|
||||||
global_to_repo!(settings, repo, syntax_highlight);
|
global_to_repo!(settings, repo, syntax_highlight);
|
||||||
global_to_repo!(settings, repo, syntax_highlight_theme);
|
global_to_repo!(settings, repo, syntax_highlight_theme);
|
||||||
@@ -395,6 +398,7 @@ impl GitsySettings {
|
|||||||
path: dir.path().clone(),
|
path: dir.path().clone(),
|
||||||
name: Some(name),
|
name: Some(name),
|
||||||
clone_url,
|
clone_url,
|
||||||
|
readme_files: settings.readme_files.clone(),
|
||||||
branch: settings.branch.clone(),
|
branch: settings.branch.clone(),
|
||||||
render_markdown: settings.render_markdown.clone(),
|
render_markdown: settings.render_markdown.clone(),
|
||||||
syntax_highlight: settings.syntax_highlight.clone(),
|
syntax_highlight: settings.syntax_highlight.clone(),
|
||||||
@@ -434,6 +438,7 @@ impl GitsySettings {
|
|||||||
path: dir.clone(),
|
path: dir.clone(),
|
||||||
name: Some(name),
|
name: Some(name),
|
||||||
clone_url,
|
clone_url,
|
||||||
|
readme_files: settings.readme_files.clone(),
|
||||||
branch: settings.branch.clone(),
|
branch: settings.branch.clone(),
|
||||||
render_markdown: settings.render_markdown.clone(),
|
render_markdown: settings.render_markdown.clone(),
|
||||||
syntax_highlight: settings.syntax_highlight.clone(),
|
syntax_highlight: settings.syntax_highlight.clone(),
|
||||||
|
|||||||
+4
-4
@@ -335,14 +335,14 @@ div.commit-page span.del {
|
|||||||
font-size: 0.9rem;
|
font-size: 0.9rem;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
table.clone-url {
|
table.links {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
}
|
}
|
||||||
table.clone-url td.field {
|
table.links td.field {
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
width: 8rem;
|
width: 10rem;
|
||||||
}
|
}
|
||||||
table.clone-url td.value {
|
table.links td.value {
|
||||||
text-align: left;
|
text-align: left;
|
||||||
}
|
}
|
||||||
div.file-contents pre {
|
div.file-contents pre {
|
||||||
|
|||||||
@@ -3,11 +3,19 @@
|
|||||||
{% block tab_summary_selected -%}selected{% endblock -%}
|
{% block tab_summary_selected -%}selected{% endblock -%}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<table class="clone-url">
|
<table class="links">
|
||||||
<colgroup>
|
<colgroup>
|
||||||
<col class="field" />
|
<col class="field" />
|
||||||
<col class="value" />
|
<col class="value" />
|
||||||
</colgroup>
|
</colgroup>
|
||||||
|
<tr class="readme">
|
||||||
|
<td class="field website">Documentation:</td>
|
||||||
|
{% if readme and readme.id in file_ids -%}
|
||||||
|
<td class="value website"><a href="{{repo_url | safe}}/{{readme.kind}}/{{readme.id}}.html">{{readme.name | default(value="[none]")}}</a></td>
|
||||||
|
{% else -%}
|
||||||
|
<td class="value website">{{readme.name | default(value="[none]")}}</td>
|
||||||
|
{% endif -%}
|
||||||
|
</tr>
|
||||||
<tr class="website">
|
<tr class="website">
|
||||||
<td class="field website">Website:</td>
|
<td class="field website">Website:</td>
|
||||||
<td class="value website">{{metadata.website | default(value="[none]")}}</td>
|
<td class="value website">{{metadata.website | default(value="[none]")}}</td>
|
||||||
|
|||||||
Reference in New Issue
Block a user