def create_site(path): name = os.path.basename(path) oxalis_dir = os.path.join(path, '_oxalis') os.mkdir(oxalis_dir) # Write site configuration config = Configuration(os.path.join(oxalis_dir, 'config')) config.set('project', 'format', '0.3') config.save() upload_conf = Configuration(os.path.join(oxalis_dir, 'upload')) upload_conf.add_section('upload') upload_conf.save() # Make upload configuration file readable only by owner # (it contains FTP password) os.chmod(os.path.join(oxalis_dir, 'upload'), 0o600) index_text_path = os.path.join(path, 'index.md') index_html_path = os.path.join(path, 'index.html') # Create default index file only if index is not already present if not (os.path.exists(index_text_path) or os.path.exists(index_html_path)): with open(index_text_path, 'w') as f: f.write(DEFAULT_INDEX.format(name=name)) templates_dir = os.path.join(path, TEMPLATES_DIR) os.mkdir(templates_dir) f = open(os.path.join(templates_dir, 'default.html'), 'w') f.write(default_template) f.close() # Create sitecopy configuration file f = open(os.path.join(oxalis_dir, 'sitecopyrc'), 'w') f.close() os.chmod(os.path.join(oxalis_dir, 'sitecopyrc'), 0o600) # Sitecopy storepath os.mkdir(os.path.join(oxalis_dir, 'sitecopy')) os.chmod(os.path.join(oxalis_dir, 'sitecopy'), 0o700)