private final Map<String, ProjectModel> projectCache = new ConcurrentHashMap<String, ProjectModel>();\r
\r
private final AtomicReference<String> repositoryListSettingsChecksum = new AtomicReference<String>("");\r
+ \r
+ private final ObjectCache<String> projectMarkdownCache = new ObjectCache<String>();\r
+ \r
+ private final ObjectCache<String> projectRepositoriesMarkdownCache = new ObjectCache<String>();\r
\r
private ServletContext servletContext;\r
\r
}\r
project.title = projectConfigs.getString("project", name, "title");\r
project.description = projectConfigs.getString("project", name, "description");\r
- configs.put(name.toLowerCase(), project); \r
+ \r
+ // project markdown\r
+ File pmkd = new File(getRepositoriesFolder(), (project.isRoot ? "" : name) + "/project.mkd");\r
+ if (pmkd.exists()) {\r
+ Date lm = new Date(pmkd.lastModified());\r
+ if (!projectMarkdownCache.hasCurrent(name, lm)) {\r
+ String mkd = com.gitblit.utils.FileUtils.readContent(pmkd, "\n");\r
+ projectMarkdownCache.updateObject(name, lm, mkd);\r
+ }\r
+ project.projectMarkdown = projectMarkdownCache.getObject(name);\r
+ }\r
+ \r
+ // project repositories markdown\r
+ File rmkd = new File(getRepositoriesFolder(), (project.isRoot ? "" : name) + "/repositories.mkd");\r
+ if (rmkd.exists()) {\r
+ Date lm = new Date(rmkd.lastModified());\r
+ if (!projectRepositoriesMarkdownCache.hasCurrent(name, lm)) {\r
+ String mkd = com.gitblit.utils.FileUtils.readContent(rmkd, "\n");\r
+ projectRepositoriesMarkdownCache.updateObject(name, lm, mkd);\r
+ }\r
+ project.repositoriesMarkdown = projectRepositoriesMarkdownCache.getObject(name);\r
+ }\r
+ \r
+ configs.put(name.toLowerCase(), project);\r
}\r
projectCache.clear();\r
projectCache.putAll(configs);\r
*/\r
package com.gitblit.wicket.pages;\r
\r
-import java.io.File;\r
-import java.io.FileInputStream;\r
-import java.io.InputStreamReader;\r
import java.text.MessageFormat;\r
import java.text.SimpleDateFormat;\r
import java.util.ArrayList;\r
import org.apache.wicket.markup.repeater.Item;\r
import org.apache.wicket.markup.repeater.data.DataView;\r
import org.apache.wicket.markup.repeater.data.ListDataProvider;\r
-import org.eclipse.jgit.lib.Constants;\r
\r
import com.gitblit.GitBlit;\r
import com.gitblit.Keys;\r
import com.gitblit.models.Metric;\r
import com.gitblit.models.ProjectModel;\r
import com.gitblit.models.RepositoryModel;\r
-import com.gitblit.models.UserModel;\r
import com.gitblit.utils.ActivityUtils;\r
import com.gitblit.utils.MarkdownUtils;\r
import com.gitblit.utils.StringUtils;\r
add(WicketUtils.syndicationDiscoveryLink(SyndicationServlet.getTitle(project.getDisplayName(),\r
null), feedLink));\r
\r
- final String projectPath;\r
- if (project.isRoot) {\r
- projectPath = "";\r
- } else {\r
- projectPath = projectName + "/";\r
- }\r
- \r
// project markdown message\r
- File pmkd = new File(GitBlit.getRepositoriesFolder(), projectPath + "project.mkd");\r
- String pmessage = readMarkdown(projectName, pmkd);\r
+ String pmessage = transformMarkdown(project.projectMarkdown);\r
Component projectMessage = new Label("projectMessage", pmessage)\r
.setEscapeModelStrings(false).setVisible(pmessage.length() > 0);\r
add(projectMessage);\r
\r
// markdown message above repositories list\r
- File rmkd = new File(GitBlit.getRepositoriesFolder(), projectPath + "repositories.mkd");\r
- String rmessage = readMarkdown(projectName, rmkd);\r
+ String rmessage = transformMarkdown(project.repositoriesMarkdown);\r
Component repositoriesMessage = new Label("repositoriesMessage", rmessage)\r
.setEscapeModelStrings(false).setVisible(rmessage.length() > 0);\r
add(repositoriesMessage);\r
}\r
return menu;\r
}\r
-\r
-\r
- private String readMarkdown(String projectName, File projectMessage) {\r
+ \r
+ private String transformMarkdown(String markdown) {\r
String message = "";\r
- if (projectMessage.exists()) {\r
+ if (!StringUtils.isEmpty(markdown)) {\r
// Read user-supplied message\r
try {\r
- FileInputStream fis = new FileInputStream(projectMessage);\r
- InputStreamReader reader = new InputStreamReader(fis,\r
- Constants.CHARACTER_ENCODING);\r
- message = MarkdownUtils.transformMarkdown(reader);\r
- reader.close();\r
+ message = MarkdownUtils.transformMarkdown(markdown);\r
} catch (Throwable t) {\r
- message = getString("gb.failedToRead") + " " + projectMessage;\r
+ message = getString("gb.failedToRead") + " " + markdown;\r
warn(message, t);\r
}\r
}\r