Skip to content

Commit

Permalink
Merge pull request #2850 from abpframework/maliming/Docs_new_Label
Browse files Browse the repository at this point in the history
Docs module "new" label improvement
  • Loading branch information
hikalkan authored Feb 18, 2020
2 parents 037ef9a + 893c8a4 commit 5bd73fd
Show file tree
Hide file tree
Showing 15 changed files with 42 additions and 34 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,8 @@ protected override void Up(MigrationBuilder migrationBuilder)
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 =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -462,6 +462,9 @@ protected override void BuildModel(ModelBuilder modelBuilder)
.IsRequired()
.HasColumnType("nvarchar(max)");

b.Property<DateTime>("CreationTime")
.HasColumnType("datetime2");

b.Property<string>("EditLink")
.HasColumnType("nvarchar(2048)")
.HasMaxLength(2048);
Expand Down Expand Up @@ -510,9 +513,6 @@ protected override void BuildModel(ModelBuilder modelBuilder)
.HasColumnType("nvarchar(2048)")
.HasMaxLength(2048);

b.Property<int>("UpdatedCount")
.HasColumnType("int");

b.Property<string>("Version")
.IsRequired()
.HasColumnType("nvarchar(128)")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ private async Task UpdateDocumentUpdateInfoCache(Document document)
await _documentUpdateCache.SetAsync(cacheKey, new DocumentUpdateInfo
{
Name = document.Name,
LastUpdatedTime = document.LastUpdatedTime,
UpdatedCount = document.UpdatedCount
CreationTime = document.CreationTime,
LastUpdatedTime = document.LastUpdatedTime
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ public class DocumentWithDetailsDto

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; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@ public virtual async Task<NavigationNode> GetNavigationAsync(GetNavigationDocume
var documentUpdateInfo = await DocumentUpdateCache.GetAsync(cacheKey);
if (documentUpdateInfo != null)
{
leaf.CreationTime = documentUpdateInfo.CreationTime;
leaf.LastUpdatedTime = documentUpdateInfo.LastUpdatedTime;
leaf.UpdatedCount = documentUpdateInfo.UpdatedCount;
}
}

Expand Down Expand Up @@ -175,8 +175,8 @@ async Task<DocumentWithDetailsDto> GetDocumentAsync()
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);
Expand Down Expand Up @@ -206,8 +206,8 @@ async Task<DocumentWithDetailsDto> GetDocumentAsync()
await DocumentUpdateCache.SetAsync(cacheKey, new DocumentUpdateInfo
{
Name = document.Name,
CreationTime = document.CreationTime,
LastUpdatedTime = document.LastUpdatedTime,
UpdatedCount = document.UpdatedCount
});

return CreateDocumentWithDetailsDto(project, document);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ public class DocumentUpdateInfo
{
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; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ public class NavigationNode

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)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ public class Document : AggregateRoot<Guid>

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; }
Expand All @@ -58,8 +58,8 @@ public Document(
[NotNull] string rootUrl,
[NotNull] string rawRootUrl,
[NotNull] string localDirectory,
DateTime creationTime,
DateTime lastUpdatedTime,
int updatedCount,
DateTime lastCachedTime
)
{
Expand All @@ -76,8 +76,9 @@ DateTime lastCachedTime
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>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ public async Task<Document> GetDocumentAsync(Project project, string documentNam
"/",
$"/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);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ await DownloadWebContentAsStringAsync(rawDocumentUrl, token, userAgent),
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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
"DocumentNotFoundInSelectedLanguage": "本文档不适用于所选语言, 将以默认语言显示文档.",
"FilterTopics": "过滤主题",
"New": "新文档",
"Upd": "更新"
"Upd": "更新",
"NewExplanation": "在最近两周内创建.",
"UpdatedExplanation": "在最近两周内更新."
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
"DocumentNotFoundInSelectedLanguage": "本文件不適用於所選語系,將以預設語系顯示.",
"FilterTopics": "過濾主題",
"New": "新文檔",
"Upd": "更新"
"Upd": "更新",
"NewExplanation": "在最近兩周內創建.",
"UpdatedExplanation": "在最近兩周內更新."
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -125,15 +125,18 @@ private string GetLeafNode(NavigationNode node, string content)
{
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;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public async Task BuildAsync()
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));
}
}
Expand Down

0 comments on commit 5bd73fd

Please sign in to comment.