Docs module "new" label improvement

Resolve #2848
pull/2850/head
maliming 6 years ago
parent 479fc27ec7
commit 893c8a42b7

@ -10,7 +10,7 @@ using VoloDocs.EntityFrameworkCore;
namespace VoloDocs.EntityFrameworkCore.Migrations
{
[DbContext(typeof(VoloDocsDbContext))]
[Migration("20200212135141_init")]
[Migration("20200218014727_init")]
partial class init
{
protected override void BuildTargetModel(ModelBuilder modelBuilder)
@ -464,6 +464,9 @@ namespace VoloDocs.EntityFrameworkCore.Migrations
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<DateTime>("CreationTime")
.HasColumnType("datetime2");
b.Property<string>("EditLink")
.HasColumnType("nvarchar(2048)")
.HasMaxLength(2048);
@ -512,9 +515,6 @@ namespace VoloDocs.EntityFrameworkCore.Migrations
.HasColumnType("nvarchar(2048)")
.HasMaxLength(2048);
b.Property<int>("UpdatedCount")
.HasColumnType("int");
b.Property<string>("Version")
.IsRequired()
.HasColumnType("nvarchar(128)")

@ -130,8 +130,8 @@ namespace VoloDocs.EntityFrameworkCore.Migrations
RootUrl = table.Column<string>(maxLength: 2048, nullable: true),
RawRootUrl = table.Column<string>(maxLength: 2048, nullable: true),
LocalDirectory = table.Column<string>(maxLength: 512, nullable: true),
CreationTime = table.Column<DateTime>(nullable: false),
LastUpdatedTime = table.Column<DateTime>(nullable: false),
UpdatedCount = table.Column<int>(nullable: false),
LastCachedTime = table.Column<DateTime>(nullable: false)
},
constraints: table =>

@ -462,6 +462,9 @@ namespace VoloDocs.EntityFrameworkCore.Migrations
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<DateTime>("CreationTime")
.HasColumnType("datetime2");
b.Property<string>("EditLink")
.HasColumnType("nvarchar(2048)")
.HasMaxLength(2048);
@ -510,9 +513,6 @@ namespace VoloDocs.EntityFrameworkCore.Migrations
.HasColumnType("nvarchar(2048)")
.HasMaxLength(2048);
b.Property<int>("UpdatedCount")
.HasColumnType("int");
b.Property<string>("Version")
.IsRequired()
.HasColumnType("nvarchar(128)")

@ -86,8 +86,8 @@ namespace Volo.Docs.Admin.Documents
await _documentUpdateCache.SetAsync(cacheKey, new DocumentUpdateInfo
{
Name = document.Name,
LastUpdatedTime = document.LastUpdatedTime,
UpdatedCount = document.UpdatedCount
CreationTime = document.CreationTime,
LastUpdatedTime = document.LastUpdatedTime
});
}

@ -27,9 +27,9 @@ namespace Volo.Docs.Documents
public virtual string LocalDirectory { get; set; }
public virtual DateTime LastUpdatedTime { get; set; }
public virtual DateTime CreationTime { get; set; }
public virtual int UpdatedCount { get; set; }
public virtual DateTime LastUpdatedTime { get; set; }
public virtual DateTime LastCachedTime { get; set; }

@ -85,8 +85,8 @@ namespace Volo.Docs.Documents
var documentUpdateInfo = await DocumentUpdateCache.GetAsync(cacheKey);
if (documentUpdateInfo != null)
{
leaf.CreationTime = documentUpdateInfo.CreationTime;
leaf.LastUpdatedTime = documentUpdateInfo.LastUpdatedTime;
leaf.UpdatedCount = documentUpdateInfo.UpdatedCount;
}
}
@ -175,8 +175,8 @@ namespace Volo.Docs.Documents
await DocumentUpdateCache.SetAsync(cacheKey, new DocumentUpdateInfo
{
Name = sourceDocument.Name,
LastUpdatedTime = sourceDocument.LastUpdatedTime,
UpdatedCount = sourceDocument.UpdatedCount
CreationTime = sourceDocument.CreationTime,
LastUpdatedTime = sourceDocument.LastUpdatedTime
});
return CreateDocumentWithDetailsDto(project, sourceDocument);
@ -206,8 +206,8 @@ namespace Volo.Docs.Documents
await DocumentUpdateCache.SetAsync(cacheKey, new DocumentUpdateInfo
{
Name = document.Name,
CreationTime = document.CreationTime,
LastUpdatedTime = document.LastUpdatedTime,
UpdatedCount = document.UpdatedCount
});
return CreateDocumentWithDetailsDto(project, document);

@ -7,8 +7,8 @@ namespace Volo.Docs.Documents
{
public virtual string Name { get; set; }
public virtual DateTime LastUpdatedTime { get; set; }
public virtual DateTime CreationTime { get; set; }
public virtual int UpdatedCount { get; set; }
public virtual DateTime LastUpdatedTime { get; set; }
}
}

@ -22,9 +22,9 @@ namespace Volo.Docs.Documents
public bool IsEmpty => Text == null && Path == null;
public DateTime? LastUpdatedTime { get; set; }
public virtual DateTime? CreationTime { get; set; }
public int UpdatedCount { get; set; }
public virtual DateTime? LastUpdatedTime { get; set; }
public bool IsSelected(string documentName)
{

@ -31,10 +31,10 @@ namespace Volo.Docs.Documents
public virtual string LocalDirectory { get; set; }
public virtual DateTime CreationTime { get; set; }
public virtual DateTime LastUpdatedTime { get; set; }
public virtual int UpdatedCount { get; set; }
public virtual DateTime LastCachedTime { get; set; }
public virtual List<DocumentContributor> Contributors { get; set; }
@ -58,8 +58,8 @@ namespace Volo.Docs.Documents
[NotNull] string rootUrl,
[NotNull] string rawRootUrl,
[NotNull] string localDirectory,
DateTime creationTime,
DateTime lastUpdatedTime,
int updatedCount,
DateTime lastCachedTime
)
{
@ -76,8 +76,9 @@ namespace Volo.Docs.Documents
RootUrl = Check.NotNullOrWhiteSpace(rootUrl, nameof(rootUrl));
RawRootUrl = Check.NotNullOrWhiteSpace(rawRootUrl, nameof(rawRootUrl));
LocalDirectory = Check.NotNull(localDirectory, nameof(localDirectory));
CreationTime = creationTime;
LastUpdatedTime = lastUpdatedTime;
UpdatedCount = updatedCount;
LastCachedTime = lastCachedTime;
Contributors = new List<DocumentContributor>();

@ -43,8 +43,8 @@ namespace Volo.Docs.FileSystem.Documents
"/",
$"/document-resources?projectId={project.Id.ToString()}&version={version}&languageCode={languageCode}&name=",
localDirectory,
File.GetCreationTime(path),
File.GetLastWriteTime(path),
File.GetLastWriteTime(path) == File.GetCreationTime(path) ? 1 : 2,
DateTime.Now);
}

@ -60,8 +60,8 @@ namespace Volo.Docs.GitHub.Documents
rootUrl,
rawRootUrl,
localDirectory,
fileCommits.LastOrDefault()?.Commit.Author.Date.DateTime ?? DateTime.MinValue,
fileCommits.FirstOrDefault()?.Commit.Author.Date.DateTime ?? DateTime.MinValue,
fileCommits.Count,
DateTime.Now);
var authors = fileCommits

@ -18,6 +18,8 @@
"DocumentNotFoundInSelectedLanguage": "本文档不适用于所选语言, 将以默认语言显示文档.",
"FilterTopics": "过滤主题",
"New": "新文档",
"Upd": "更新"
"Upd": "更新",
"NewExplanation": "在最近两周内创建.",
"UpdatedExplanation": "在最近两周内更新."
}
}

@ -18,6 +18,8 @@
"DocumentNotFoundInSelectedLanguage": "本文件不適用於所選語系,將以預設語系顯示.",
"FilterTopics": "過濾主題",
"New": "新文檔",
"Upd": "更新"
"Upd": "更新",
"NewExplanation": "在最近兩周內創建.",
"UpdatedExplanation": "在最近兩周內更新."
}
}

@ -125,15 +125,18 @@ namespace Volo.Docs.Areas.Documents.TagHelpers
{
var badge = "";
if (!node.Path.IsNullOrWhiteSpace() && node.LastUpdatedTime.HasValue && node.LastUpdatedTime + TimeSpan.FromDays(14) > DateTime.Now)
if (!node.Path.IsNullOrWhiteSpace() && node.CreationTime.HasValue && node.LastUpdatedTime.HasValue)
{
if (node.UpdatedCount > 1)
var newBadge = "<span class='badge badge-primary ml-2' title=\"" + _localizer["NewExplanation"] + "\">" + _localizer["New"] + "</span>";
var updBadge = "<span class='badge badge-light ml-2' title=\"" + _localizer["UpdatedExplanation"] + "\">" + _localizer["Upd"] + "</span>";
if(node.CreationTime + TimeSpan.FromDays(14) > DateTime.Now)
{
badge = "<span class='badge badge-light ml-2' title=\"" + _localizer["UpdatedExplanation"] + "\">" + _localizer["Upd"] + "</span>";
badge = newBadge;
}
else
else if (node.LastUpdatedTime + TimeSpan.FromDays(14) > DateTime.Now)
{
badge = "<span class='badge badge-primary ml-2' title=\"" + _localizer["NewExplanation"] + "\">" + _localizer["New"] + "</span>";
badge = updBadge;
}
}

@ -47,7 +47,7 @@ namespace Volo.Docs
await _documentRepository.InsertAsync(new Document(Guid.NewGuid(), project.Id, "CLI.md", "2.0.0", "en", "CLI.md",
"this is abp cli", "md", "https://github.com/abpframework/abp/blob/2.0.0/docs/en/CLI.md",
"https://github.com/abpframework/abp/tree/2.0.0/docs/",
"https://raw.githubusercontent.com/abpframework/abp/2.0.0/docs/en/", "", DateTime.Now, 1,
"https://raw.githubusercontent.com/abpframework/abp/2.0.0/docs/en/", "", DateTime.Now, DateTime.Now,
DateTime.Now));
}
}

Loading…
Cancel
Save