Skip to content

Commit

Permalink
Merge remote-tracking branch 'master/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
ThirtyDegreesRay committed Dec 4, 2018
2 parents 193a21f + b3dfc40 commit e1548eb
Show file tree
Hide file tree
Showing 5 changed files with 396 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public class Repository implements Parcelable {
@SerializedName("clone_url") private String cloneUrl ;
@SerializedName("svn_url") private String svnUrl ;

private int size ;
private long size ;
@SerializedName("stargazers_count") private int stargazersCount ;
@SerializedName("watchers_count") private int watchersCount ;
@SerializedName("forks_count") private int forksCount ;
Expand Down Expand Up @@ -258,11 +258,11 @@ public void setSvnUrl(String svnUrl) {
this.svnUrl = svnUrl;
}

public int getSize() {
public long getSize() {
return size;
}

public void setSize(int size) {
public void setSize(long size) {
this.size = size;
}

Expand Down Expand Up @@ -409,7 +409,7 @@ public void writeToParcel(Parcel dest, int flags) {
dest.writeString(this.sshUrl);
dest.writeString(this.cloneUrl);
dest.writeString(this.svnUrl);
dest.writeInt(this.size);
dest.writeLong(this.size);
dest.writeInt(this.stargazersCount);
dest.writeInt(this.watchersCount);
dest.writeInt(this.forksCount);
Expand Down Expand Up @@ -448,7 +448,7 @@ protected Repository(Parcel in) {
this.sshUrl = in.readString();
this.cloneUrl = in.readString();
this.svnUrl = in.readString();
this.size = in.readInt();
this.size = in.readLong();
this.stargazersCount = in.readInt();
this.watchersCount = in.readInt();
this.forksCount = in.readInt();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@ static String generateMdHtml(@NonNull String mdSource, @Nullable String baseUrl,
@NonNull String accentColor, boolean wrapCode) {
String skin = isDark ? "markdown_dark.css" : "markdown_white.css";
mdSource = StringUtils.isBlank(baseUrl) ? mdSource : fixLinks(mdSource, baseUrl);
//fix wiki inner url like this "href="/robbyrussell/oh-my-zsh/wiki/Themes""
mdSource = fixWikiLinks(mdSource);
return generateMdHtml(mdSource, skin, backgroundColor, accentColor, wrapCode);
}

Expand Down Expand Up @@ -137,6 +139,21 @@ private static String formatCode(@NonNull String codeSource) {
return codeSource.replaceAll("<", "&lt;").replaceAll(">", "&gt;");
}

private static String fixWikiLinks(@NonNull String source) {
Matcher linksMatcher = LINK_PATTERN.matcher(source);
while (linksMatcher.find()) {
while (linksMatcher.find()) {
String oriUrl = linksMatcher.group(1);
String fixedUrl;
if (oriUrl.startsWith("/") && oriUrl.contains("/wiki/")) {
fixedUrl = "https://github.com" + oriUrl;
source = source.replace("href=\"" + oriUrl + "\"", "href=\"" + fixedUrl + "\"");
}
}
}
return source;
}

private static String fixLinks(@NonNull String source, @NonNull String baseUrl) {
GitHubName gitHubName = GitHubName.fromUrl(baseUrl);
if (gitHubName == null) return source;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ public static String getSizeString(long size){
}else if(size < 1024 * 1024 * 1024){
float sizeM = size / (1024f * 1024f);
return String.format(Locale.getDefault(), "%.2f MB", sizeM);
}else if(size / 1024 < 1024 * 1024 * 1024){
float sizeG = size / (1024f * 1024f * 1024f);
return String.format(Locale.getDefault(), "%.2f GB", sizeG);
}
return null;
}
Expand Down
Loading

0 comments on commit e1548eb

Please sign in to comment.