You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@carbondata.apache.org by ch...@apache.org on 2017/04/12 11:52:16 UTC

[48/54] incubator-carbondata-site git commit: Added links to application.conf

Added links to application.conf


Project: http://git-wip-us.apache.org/repos/asf/incubator-carbondata-site/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-carbondata-site/commit/641e61bd
Tree: http://git-wip-us.apache.org/repos/asf/incubator-carbondata-site/tree/641e61bd
Diff: http://git-wip-us.apache.org/repos/asf/incubator-carbondata-site/diff/641e61bd

Branch: refs/heads/asf-site
Commit: 641e61bdb452ef01d6bfd1c7ef2d877ab4c90e5a
Parents: 6e0e899
Author: jatin <ja...@knoldus.in>
Authored: Thu Apr 6 17:20:59 2017 +0530
Committer: jatin <ja...@knoldus.in>
Committed: Thu Apr 6 17:20:59 2017 +0530

----------------------------------------------------------------------
 src/main/resources/application.conf   |  7 ++++++-
 src/main/scala/FileModification.scala | 17 ++++++++++-------
 src/main/scala/MdFilehandler.scala    | 17 ++++++++++-------
 3 files changed, 26 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-carbondata-site/blob/641e61bd/src/main/resources/application.conf
----------------------------------------------------------------------
diff --git a/src/main/resources/application.conf b/src/main/resources/application.conf
index a4f0f94..fe8f999 100644
--- a/src/main/resources/application.conf
+++ b/src/main/resources/application.conf
@@ -8,4 +8,9 @@ fileList=["configuration-parameters",
   "supported-data-types-in-carbondata",
   "troubleshooting",
   "useful-tips-on-carbondata"
-  ]
\ No newline at end of file
+  ]
+headerPath="src/main/scala/html/header.html"
+footerPath="src/main/scala/html/footer.html"
+outputFileLocation="src/main/webapp/"
+apiUrl="https://raw.githubusercontent.com/apache/incubator-carbondata/master/docs/"
+mdLink="https://api.github.com/markdown/raw"
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-carbondata-site/blob/641e61bd/src/main/scala/FileModification.scala
----------------------------------------------------------------------
diff --git a/src/main/scala/FileModification.scala b/src/main/scala/FileModification.scala
index 1a5580d..e7b3e8f 100644
--- a/src/main/scala/FileModification.scala
+++ b/src/main/scala/FileModification.scala
@@ -1,25 +1,26 @@
 import java.io.{File, PrintWriter}
-import collection.JavaConverters._
 
 import com.typesafe.config.ConfigFactory
 import org.slf4j.LoggerFactory
 
+import scala.collection.JavaConverters._
+
 class FileModification {
   val logger = LoggerFactory.getLogger(classOf[FileModification])
-  val url = "https://raw.githubusercontent.com/apache/incubator-carbondata/master/docs/"
+  val url = ConfigFactory.load().getString("apiUrl")
   val inputFileExtension = ".md"
   val outputFileExtension = ".html"
 
   import scala.io.Source
+  val headerContent: String = Source.fromFile(ConfigFactory.load().getString("headerPath")).mkString
+  val footerContent: String = Source.fromFile(ConfigFactory.load().getString("footerPath")).mkString
 
-  val headerContent: String = Source.fromFile("src/main/scala/html/header.html").mkString
-  val footerContent: String =Source.fromFile("src/main/scala/html/footer.html").mkString
-
-  val location = "src/main/webapp/"
+  val location = ConfigFactory.load().getString("outputFileLocation")
   val fileReadObject = new MdFilehandler
 
   /**
-    * reads list of files , converts file extension to output file extension and writes file to the locaion
+    * reads list of files , converts file extension to output file extension and writes file to the location
+    *
     * @return status of each file i.e. success or failure
     */
   def convertToHtml(): String = {
@@ -46,6 +47,7 @@ class FileModification {
 
   /**
     * Reads list of files from application.conf file
+    *
     * @return list of string
     */
   private def readListOfFiles(): List[String] = {
@@ -56,6 +58,7 @@ class FileModification {
 
   /**
     * writes file to the destination provided by path parameter
+    *
     * @param path storage location of the file
     * @param data contents of the file
     */

http://git-wip-us.apache.org/repos/asf/incubator-carbondata-site/blob/641e61bd/src/main/scala/MdFilehandler.scala
----------------------------------------------------------------------
diff --git a/src/main/scala/MdFilehandler.scala b/src/main/scala/MdFilehandler.scala
index 72eedd6..afb427a 100644
--- a/src/main/scala/MdFilehandler.scala
+++ b/src/main/scala/MdFilehandler.scala
@@ -1,10 +1,12 @@
-import scala.util.matching.Regex
+import com.typesafe.config.ConfigFactory
 import org.apache.http.HttpResponse
 import org.apache.http.client.methods.HttpPost
 import org.apache.http.impl.client.DefaultHttpClient
 import org.apache.http.util.EntityUtils
 import org.slf4j.LoggerFactory
 
+import scala.util.matching.Regex
+
 /**
   * Created by pallavi on 4/4/17.
   */
@@ -15,15 +17,16 @@ class MdFilehandler {
   /**
     * converts .md extension to .html extension
     * changes location of image from local to git repository
+    *
     * @param input
     * @return contents of file
     */
   def ConvertMdExtension(input: String): String = {
     val modifyContentPattern = new Regex("id=\"user-content-")
     val modifyMdPattern = new Regex(".md")
-    val modifyImagePattern=new Regex("<img src=\"../docs")
-    val modifyHttpsFileLink="""(<a href=\"https)://([a-zA-Z0-9-/.]+)(\")""".r
-    val modifyHttpFileLink="""(<a href=\"http)://([a-zA-Z0-9-/.]+)(\")""".r
+    val modifyImagePattern = new Regex("<img src=\"../docs")
+    val modifyHttpsFileLink ="""(<a href=\"https)://([a-zA-Z0-9-/.]+)(\")""".r
+    val modifyHttpFileLink ="""(<a href=\"http)://([a-zA-Z0-9-/.]+)(\")""".r
     val contentAfterRemovingUserContent: String = modifyContentPattern replaceAllIn(input, "id=\"")
     val contentAfterReplacingId: String = modifyMdPattern replaceAllIn(contentAfterRemovingUserContent, ".html")
     val contentAfterReplacingImage: String = modifyImagePattern replaceAllIn(contentAfterReplacingId, "<img src=\"https://github.com/apache/incubator-carbondata/blob/master/docs")
@@ -34,12 +37,13 @@ class MdFilehandler {
 
   /**
     * gets content of the file through rest call
+    *
     * @param data file Url
     * @return contents of the file in responseBody if found else None is returned
     */
   def getFileContent(data: String): Option[String] = {
     val httpClient = new DefaultHttpClient()
-    val httpRequest: HttpPost = new HttpPost("https://api.github.com/markdown/raw");
+    val httpRequest: HttpPost = new HttpPost(ConfigFactory.load().getString("mdLink"));
     httpRequest.setHeader("Content-type", "text/plain")
 
     import org.apache.http.entity.StringEntity;
@@ -48,8 +52,7 @@ class MdFilehandler {
     val httpResponse: HttpResponse = httpClient.execute(httpRequest)
     val responseBody = EntityUtils.toString(httpResponse.getEntity())
     logger.info(s"status : {${httpResponse.getStatusLine.toString.contains("OK")}}")
-    // println("--------->" + responseBody.toString)
-    if(httpResponse.getStatusLine.toString.contains("OK"))
+    if (httpResponse.getStatusLine.toString.contains("OK"))
       Some(responseBody.toString)
     else {
       logger.error(s"Fetching file fails {${httpResponse.getStatusLine}}")