Commits

joberschweiber committed c526c14

Publish to separate publish path

  • Participants
  • Parent commits 5c35b62

Comments (0)

Files changed (1)

File rhodecode/lib/celerylib/tasks.py

 def publish_page(repository):
     log = logging.getLogger(__name__)
     log.info('Publishing repository %s' % repository)
-    base_path = config['app_conf'].get('pages_base_path')
+    base_path = config['app_conf'].get('pages_temp_path')
+    pub_path = config['app_conf'].get('pages_publish_path')
     vhosts_path = config['app_conf'].get('pages_vhost_map')
     host_ext = config['app_conf'].get('pages_host_ext')
     jekyll_path = config['app_conf'].get('pages_jekyll')
+    # First we get the latest changeset on the rc-pages branch
+    # and copy all files and folders to the base path
     repos_path = get_repos_path()
     repo = get_repo(safe_str(os.path.join(repos_path, repository)))
     pages_cs = repo.get_changeset('rc-pages')
             f = open(file_path, 'wb')
             f.write(pages_cs.get_file_content(node.path))
             f.close()
+    # Next we update the vhost map with the publish path
+    pub_host_base = os.path.join(pub_path, hostname)
+    if not os.path.exists(pub_host_base):
+        os.mkdir(pub_host_base)
+    pub_repo_base = os.path.join(pub_host_base, directory)
+    if not os.path.exists(pub_repo_base):
+        os.mkdir(pub_repo_base)
     vhosts_file = open(vhosts_path, 'r')
     vhosts_map = dict([line.strip().split(' ') for line in vhosts_file.readlines()])
     vhosts_file.close()
     real_host = hostname + host_ext
-    log.info('Registering name %s for directory %s' % (real_host, host_base))
-    vhosts_map[real_host] = host_base
+    log.info('Registering name %s for directory %s' % (real_host, pub_host_base))
+    vhosts_map[real_host] = pub_host_base
     if cname != None:
-        log.info('Registering name %s for directory %s' % (cname, repo_base))
-        vhosts_map[cname] = repo_base
+        log.info('Registering name %s for directory %s' % (cname, pub_repo_base))
+        vhosts_map[cname] = pub_repo_base
     vhosts_file = open(vhosts_path, 'w')
     vhosts_file.writelines([i + ' ' + vhosts_map[i] + "\r\n" for i in vhosts_map])
     vhosts_file.close()
-    subprocess.call([jekyll_path, "--pygments", "--safe", repo_base, os.path.join(repo_base, '_site')])
+    # Finally we ask jekyll to publish from base to publish
+    subprocess.call([jekyll_path, "--pygments", "--safe", repo_base, pub_repo_base])