@@ -326,15 +326,14 @@ class HashAuthenticatedCommand(object): | |||
def clear_cache(user=None, doctype=None): | |||
"""clear cache""" | |||
from webnotes.sessions import clear_cache | |||
if doctype: | |||
from webnotes.model.doctype import clear_cache | |||
clear_cache(doctype) | |||
reset_metadata_version() | |||
elif user: | |||
from webnotes.sessions import clear_cache | |||
clear_cache(user) | |||
else: # everything | |||
from webnotes.sessions import clear_cache | |||
clear_cache() | |||
reset_metadata_version() | |||
@@ -484,6 +483,9 @@ def insert(doclist): | |||
def get_module(modulename): | |||
return importlib.import_module(modulename) | |||
def get_pymodule_path(modulename): | |||
return os.path.dirname(get_module(modulename).__file__) | |||
def get_module_list(app_name): | |||
return get_file_items(os.path.join(os.path.dirname(get_module(app_name).__file__), "modules.txt")) | |||
@@ -500,7 +502,7 @@ def setup_module_map(): | |||
if not local.app_modules: | |||
local.module_app, local.app_modules = {}, {} | |||
for app in ["webnotes"] + get_app_list(): | |||
for app in get_app_list(True): | |||
for module in get_module_list(app): | |||
local.module_app[module] = app | |||
local.app_modules.setdefault(app, []) | |||
@@ -595,16 +597,21 @@ def get_list(doctype, filters=None, fields=None, docstatus=None, | |||
group_by=group_by, order_by=order_by, limit_start=limit_start, limit_page_length=limit_page_length, | |||
as_list=as_list, debug=debug) | |||
jenv = None | |||
def get_jenv(): | |||
from jinja2 import Environment, FileSystemLoader | |||
from webnotes.utils import get_base_path, global_date_format | |||
from markdown2 import markdown | |||
from json import dumps | |||
jenv = Environment(loader = FileSystemLoader(get_base_path())) | |||
jenv.filters["global_date_format"] = global_date_format | |||
jenv.filters["markdown"] = markdown | |||
jenv.filters["json"] = dumps | |||
global jenv | |||
if not jenv: | |||
from jinja2 import Environment, ChoiceLoader, PackageLoader | |||
from webnotes.utils import get_base_path, global_date_format | |||
from markdown2 import markdown | |||
from json import dumps | |||
jenv = Environment(loader = ChoiceLoader([PackageLoader(app, ".") \ | |||
for app in get_app_list(True)])) | |||
jenv.filters["global_date_format"] = global_date_format | |||
jenv.filters["markdown"] = markdown | |||
jenv.filters["json"] = dumps | |||
return jenv | |||
@@ -13,7 +13,6 @@ from werkzeug.local import LocalManager | |||
from webnotes.middlewares import StaticDataMiddleware | |||
from werkzeug.exceptions import HTTPException, NotFound | |||
from werkzeug.contrib.profiler import ProfilerMiddleware | |||
from webnotes import get_config | |||
import mimetypes | |||
import webnotes | |||
@@ -22,7 +21,7 @@ import webnotes.auth | |||
import webnotes.webutils | |||
local_manager = LocalManager([webnotes.local]) | |||
site_path = None | |||
site = None | |||
def handle_session_stopped(): | |||
res = Response("""<html> | |||
@@ -42,7 +41,7 @@ def application(request): | |||
webnotes.local.request = request | |||
try: | |||
webnotes.init(site_path=site_path or request.host) | |||
webnotes.init(site=site or request.host) | |||
webnotes.local.form_dict = webnotes._dict({ k:v[0] if isinstance(v, (list, tuple)) else v \ | |||
for k, v in (request.form or request.args).iteritems() }) | |||
@@ -75,18 +74,22 @@ def application(request): | |||
application = local_manager.make_middleware(application) | |||
if not os.environ.get('NO_STATICS'): | |||
application = StaticDataMiddleware(application, { | |||
'/': 'public', | |||
}) | |||
def serve(port=8000, profile=False): | |||
global application | |||
global application, site | |||
site = webnotes.local.site | |||
from werkzeug.serving import run_simple | |||
if profile: | |||
application = ProfilerMiddleware(application) | |||
if not os.environ.get('NO_STATICS'): | |||
application = StaticDataMiddleware(application, { | |||
'/': 'public', | |||
}) | |||
application.site = site | |||
run_simple('0.0.0.0', int(port), application, use_reloader=True, | |||
use_debugger=True, use_evalex=True) |
@@ -42,7 +42,7 @@ def make_site_public_dirs(): | |||
os.makedirs(dir_path) | |||
# symlink app/public > assets/app | |||
for app_name in webnotes.get_app_list(): | |||
for app_name in webnotes.get_app_list(True): | |||
pymodule = webnotes.get_module(app_name) | |||
source = os.path.join(os.path.abspath(os.path.dirname(pymodule.__file__)), 'public') | |||
target = os.path.join(assets_path, app_name) | |||
@@ -127,7 +127,8 @@ def pack(target, sources, no_compress): | |||
print webnotes.getTraceback() | |||
if not no_compress and outtype == 'css': | |||
outtxt = cssmin(outtxt) | |||
pass | |||
#outtxt = cssmin(outtxt) | |||
with open(target, 'w') as f: | |||
f.write(outtxt.encode("utf-8")) | |||
@@ -0,0 +1,19 @@ | |||
{ | |||
"中国(简体)": "zh-cn", | |||
"中國(繁體)": "zh-tw", | |||
"deutsch": "de", | |||
"ελληνικά": "el", | |||
"english": "en", | |||
"español": "es", | |||
"français": "fr", | |||
"हिंदी": "hi", | |||
"hrvatski": "hr", | |||
"italiano": "it", | |||
"nederlands": "nl", | |||
"português brasileiro": "pt-BR", | |||
"português": "pt", | |||
"српски":"sr", | |||
"தமிழ்": "ta", | |||
"ไทย": "th", | |||
"العربية":"ar" | |||
} |
@@ -88,14 +88,9 @@ class Installer: | |||
# update admin password | |||
self.update_admin_password(admin_password) | |||
# create public folder | |||
# from webnotes.install_lib import setup_public_folder | |||
# setup_public_folder.make(site=self.site) | |||
# | |||
# if not self.site: | |||
# from webnotes.build import bundle | |||
# bundle(False) | |||
# | |||
from webnotes.build import bundle | |||
bundle(False) | |||
return db_name | |||
def install_app(self, name, verbose=False): | |||
@@ -105,13 +100,13 @@ class Installer: | |||
sync_for(name, force=True, sync_everything=True, verbose=verbose) | |||
from webnotes.website.doctype.website_sitemap_config.website_sitemap_config import build_website_sitemap_config | |||
build_website_sitemap_config(name) | |||
if hasattr(manage, "after_install"): | |||
manage.after_install() | |||
def install_app_old(self, verbose=False): | |||
sync_for("lib", force=True, sync_everything=True, verbose=verbose) | |||
self.import_core_docs() | |||
@@ -127,8 +122,6 @@ class Installer: | |||
install_fixtures() | |||
# build website sitemap | |||
from webnotes.website.doctype.website_sitemap_config.website_sitemap_config import build_website_sitemap_config | |||
build_website_sitemap_config() | |||
if verbose: print "Completing App Import..." | |||
install and install.post_import() | |||
@@ -13,21 +13,10 @@ class StaticDataMiddleware(SharedDataMiddleware): | |||
def get_directory_loader(self, directory): | |||
def loader(path): | |||
import conf | |||
path = cstr(path) | |||
fail = True | |||
if hasattr(conf, 'sites_dir'): | |||
site = get_site_name(self.environ.get('HTTP_HOST')) | |||
possible_site_path = get_path(directory, path, base=os.path.join(conf.sites_dir, site)) | |||
if os.path.isfile(possible_site_path): | |||
path = possible_site_path | |||
fail = False | |||
if fail and os.path.isfile(get_path(directory, path)): | |||
path = get_path(directory, path) | |||
fail = False | |||
if fail: | |||
filepath = os.path.join(os.path.join(".", self.site), directory, path) | |||
if os.path.isfile(filepath): | |||
return os.path.basename(filepath), self._opener(filepath) | |||
else: | |||
return None, None | |||
return os.path.basename(path), self._opener(path) | |||
return loader |
@@ -4,9 +4,9 @@ | |||
<title>ERPNext</title> | |||
<meta name="author" content=""> | |||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |||
<link rel="shortcut icon" href="app/images/favicon.ico" type="image/x-icon"> | |||
<link rel="icon" href="app/images/favicon.ico" type="image/x-icon"> | |||
<link type="text/css" rel="stylesheet" href="app/css/splash.css"> | |||
<link rel="shortcut icon" href="images/favicon.ico" type="image/x-icon"> | |||
<link rel="icon" href="images/favicon.ico" type="image/x-icon"> | |||
<link type="text/css" rel="stylesheet" href="css/splash.css"> | |||
</head> | |||
<body> | |||
<div class="splash">%(splash)s</div> | |||
@@ -15,7 +15,7 @@ | |||
</div> | |||
<footer></footer> | |||
<link type="text/css" rel="stylesheet" href="css/all-app.css"> | |||
<script type="text/javascript" src="lib/js/lib/jquery/jquery.min.js"></script> | |||
<script type="text/javascript" src="js/lib/jquery/jquery.min.js"></script> | |||
<script type="text/javascript"> | |||
window._version_number = "%(_version_number)s"; | |||
// browser support | |||
@@ -17,7 +17,7 @@ import json | |||
import re | |||
from csv import reader | |||
from webnotes.modules import get_doc_path,get_doctype_module | |||
from webnotes.utils import get_base_path, cstr | |||
from webnotes.utils import cstr | |||
def translate(lang=None): | |||
languages = [lang] | |||
@@ -52,7 +52,7 @@ def get_all_languages(): | |||
raise | |||
def get_lang_dict(): | |||
languages_path = os.path.join(get_base_path(), "app", "translations", "languages.json") | |||
languages_path = os.path.join(os.path.dirname(webnotes.__file__), "data", "languages.json") | |||
if os.path.exists(languages_path): | |||
with open(languages_path, "r") as langfile: | |||
return json.loads(langfile.read()) | |||
@@ -15,21 +15,21 @@ | |||
<!-- end blog content --> | |||
{% if blogger_info %} | |||
<hr /> | |||
{% include "lib/website/doctype/blog_post/templates/includes/blogger.html" %} | |||
{% include "website/doctype/blog_post/templates/includes/blogger.html" %} | |||
{% endif %} | |||
<hr> | |||
<h3>Comments</h3> | |||
{% include 'lib/website/templates/includes/comments.html' %} | |||
{% include 'website/templates/includes/comments.html' %} | |||
</div> | |||
<script> | |||
$(function() { | |||
if(window.logged_in && getCookie("system_user")==="yes") { | |||
wn.has_permission("Blog Post", "{{ name }}", "write", function(r) { | |||
wn.require("lib/js/wn/website/editable.js"); | |||
wn.require("js/wn/website/editable.js"); | |||
wn.make_editable($('[itemprop="articleBody"]'), "Blog Post", "{{ name }}", "content"); | |||
}); | |||
} | |||
}); | |||
</script> | |||
{% include 'lib/website/doctype/blog_post/templates/includes/blog_footer.html' %} | |||
{% include 'website/doctype/blog_post/templates/includes/blog_footer.html' %} | |||
{% endblock %} |
@@ -4,6 +4,6 @@ | |||
<button class="btn btn-warning btn-blog-subscribe">Get Updates via Email</button> | |||
</p> | |||
<p> | |||
<img src="app/images/feed.png" style="margin-right: 4px; margin-bottom: -4px"> | |||
<img src="images/feed.png" style="margin-right: 4px; margin-bottom: -4px"> | |||
<a href="rss.xml" target="_blank">RSS Feed</a> | |||
</p> |
@@ -2,13 +2,13 @@ | |||
{% block javascript %} | |||
<script> | |||
{% include "lib/website/doctype/blog_post/templates/includes/blog.js" %} | |||
{% include "website/doctype/blog_post/templates/includes/blog.js" %} | |||
</script> | |||
{% endblock %} | |||
{% block css %} | |||
<style> | |||
{% include "lib/website/doctype/blog_post/templates/includes/blog.css" %} | |||
{% include "website/doctype/blog_post/templates/includes/blog.css" %} | |||
</style> | |||
{% endblock %} | |||
@@ -33,5 +33,5 @@ | |||
style="display:none;">More...</button> | |||
</div> | |||
</div> | |||
{% include 'lib/website/doctype/blog_post/templates/includes/blog_footer.html' %} | |||
{% include 'website/doctype/blog_post/templates/includes/blog_footer.html' %} | |||
{% endblock %} |
@@ -10,9 +10,9 @@ | |||
{% endif %} | |||
<hr> | |||
{% for blogger_info in bloggers %} | |||
{% include "lib/website/doctype/blog_post/templates/includes/blogger.html" %} | |||
{% include "website/doctype/blog_post/templates/includes/blogger.html" %} | |||
{% if not loop.last %}<hr>{% endif %} | |||
{% endfor %} | |||
</div> | |||
{% include 'lib/website/doctype/blog_post/templates/includes/blog_footer.html' %} | |||
{% include 'website/doctype/blog_post/templates/includes/blog_footer.html' %} | |||
{% endblock %} |
@@ -2,7 +2,7 @@ | |||
{% block javascript %} | |||
<script> | |||
{% include "lib/website/doctype/contact_us_settings/templates/includes/contact.js" %} | |||
{% include "website/doctype/contact_us_settings/templates/includes/contact.js" %} | |||
</script> | |||
{% endblock %} | |||
@@ -15,7 +15,7 @@ | |||
{%- endif %} | |||
{%- endblock %} | |||
{% include "lib/website/doctype/website_slideshow/templates/includes/slideshow.html" %} | |||
{% include "website/doctype/website_slideshow/templates/includes/slideshow.html" %} | |||
<div class="web-page-content" id="{{ name }}"> | |||
{{ main_section or "" }} | |||
</div> | |||
@@ -50,7 +50,7 @@ | |||
{% if enable_comments -%} | |||
<hr> | |||
<h3>Discuss</h3> | |||
{% include 'lib/website/templates/includes/comments.html' %} | |||
{% include 'website/templates/includes/comments.html' %} | |||
{%- endif %} | |||
{%- endblock %} | |||
</div> | |||
@@ -58,7 +58,7 @@ | |||
$(function() { | |||
if(window.logged_in && getCookie("system_user")==="yes") { | |||
wn.has_permission("Web Page", "{{ name }}", "write", function(r) { | |||
wn.require("lib/js/wn/website/editable.js"); | |||
wn.require("js/wn/website/editable.js"); | |||
wn.make_editable($(".web-page-content"), "Web Page", "{{ name }}", "main_section"); | |||
}); | |||
} | |||
@@ -37,28 +37,26 @@ def rebuild_website_sitemap_config(): | |||
webnotes.conn.sql("""delete from `tabWebsite Sitemap`""") | |||
build_website_sitemap_config() | |||
def build_website_sitemap_config(): | |||
def build_website_sitemap_config(app): | |||
config = {"pages": {}, "generators":{}} | |||
basepath = webnotes.utils.get_base_path() | |||
basepath = webnotes.get_pymodule_path(app) | |||
existing_configs = dict(webnotes.conn.sql("""select name, lastmod from `tabWebsite Sitemap Config`""")) | |||
for path, folders, files in os.walk(basepath, followlinks=True): | |||
for ignore in ('locale', 'public'): | |||
if ignore in folders: | |||
folders.remove(ignore) | |||
for dontwalk in ('locale', 'public', '.git', app+".egg-info"): | |||
if dontwalk in folders: | |||
folders.remove(dontwalk) | |||
if os.path.basename(path)=="pages" and os.path.basename(os.path.dirname(path))=="templates": | |||
for fname in files: | |||
fname = webnotes.utils.cstr(fname) | |||
if fname.split(".")[-1] in ("html", "xml", "js", "css"): | |||
name = add_website_sitemap_config("Page", path, fname, existing_configs) | |||
name = add_website_sitemap_config("Page", app, path, fname, existing_configs, basepath) | |||
if name in existing_configs: del existing_configs[name] | |||
if os.path.basename(path)=="generators" and os.path.basename(os.path.dirname(path))=="templates": | |||
for fname in files: | |||
if fname.endswith(".html"): | |||
name = add_website_sitemap_config("Generator", path, fname, existing_configs) | |||
name = add_website_sitemap_config("Generator", app, path, fname, existing_configs, basepath) | |||
if name in existing_configs: del existing_configs[name] | |||
for name in existing_configs: | |||
@@ -66,14 +64,11 @@ def build_website_sitemap_config(): | |||
webnotes.conn.commit() | |||
def add_website_sitemap_config(page_or_generator, path, fname, existing_configs): | |||
basepath = webnotes.utils.get_base_path() | |||
template_path = os.path.relpath(os.path.join(path, fname), basepath) | |||
lastmod = int(os.path.getmtime(template_path)) | |||
def add_website_sitemap_config(page_or_generator, app, path, fname, existing_configs, basepath): | |||
lastmod = int(os.path.getmtime(os.path.join(path, fname))) | |||
name = fname[:-5] if fname.endswith(".html") else fname | |||
config_lastmod = existing_configs.get(name) | |||
if str(config_lastmod) != str(lastmod): | |||
webnotes.delete_doc("Website Sitemap Config", name) | |||
else: | |||
@@ -84,15 +79,14 @@ def add_website_sitemap_config(page_or_generator, path, fname, existing_configs) | |||
"doctype": "Website Sitemap Config", | |||
"page_or_generator": page_or_generator, | |||
"link_name": name, | |||
"template_path": template_path, | |||
"template_path": os.path.relpath(os.path.join(path, fname), basepath), | |||
"lastmod": lastmod | |||
}) | |||
controller_name = fname.split(".")[0].replace("-", "_") + ".py" | |||
controller_path = os.path.join(path, controller_name) | |||
if os.path.exists(controller_path): | |||
wsc.controller = os.path.relpath(controller_path[:-3], basepath).replace(os.path.sep, ".") | |||
wsc.controller = ".".join(wsc.controller.split(".")[1:]) | |||
wsc.controller = app + "." + os.path.relpath(controller_path[:-3], basepath).replace(os.path.sep, ".") | |||
if wsc.controller: | |||
module = webnotes.get_module(wsc.controller) | |||
@@ -5,11 +5,9 @@ | |||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |||
<title>{{ title }}</title> | |||
<meta name="generator" content="wnframework"> | |||
<script type="text/javascript" src="lib/js/lib/jquery/jquery.min.js"></script> | |||
<script type="text/javascript" src="js/all-web.min.js"></script> | |||
<script type="text/javascript" src="wn-web.js"></script> | |||
<link type="text/css" rel="stylesheet" href="css/all-web.css"> | |||
<link type="text/css" rel="stylesheet" href="wn-web.css"> | |||
<script type="text/javascript" src="assets/webnotes/js/lib/jquery/jquery.min.js"></script> | |||
<script type="text/javascript" src="assets/webnotes-web.min.js"></script> | |||
<link type="text/css" rel="stylesheet" href="assets/css/webnotes-web.css"> | |||
<link rel="shortcut icon" href="{{ favicon }}" type="image/x-icon"> | |||
<link rel="icon" href="{{ favicon }}" type="image/x-icon"> | |||
{% block head %}{% endblock %} | |||
@@ -24,10 +22,10 @@ | |||
</head> | |||
<body> | |||
{% block banner %}{{ banner_html or "" }}{% endblock %} | |||
{% block navbar %}{% include "lib/website/templates/includes/navbar.html" %}{% endblock %} | |||
{% block navbar %}{% include "website/templates/includes/navbar.html" %}{% endblock %} | |||
<div class="page-container" id="page-{{ name }}"> | |||
{% block content %}{% endblock %} | |||
</div> | |||
{% block footer %}{% include "lib/website/templates/includes/footer.html" %}{% endblock %} | |||
{% block footer %}{% include "website/templates/includes/footer.html" %}{% endblock %} | |||
</body> | |||
</html> |
@@ -6,7 +6,7 @@ | |||
<div itemscope itemtype="http://schema.org/UserComments" id="comment-list"> | |||
{% for comment in comment_list %} | |||
{% include "lib/website/templates/includes/comment.html" %} | |||
{% include "website/templates/includes/comment.html" %} | |||
{% endfor %} | |||
</div> | |||
@@ -5,7 +5,7 @@ | |||
{% block javascript %} | |||
<script> | |||
{% include "lib/website/templates/includes/login.js" %} | |||
{% include "website/templates/includes/login.js" %} | |||
</script> | |||
{% endblock %} | |||
@@ -53,7 +53,7 @@ | |||
<div class="form-group"> | |||
<button type="submit" id="login_btn" | |||
class="btn btn-primary">Login</button> | |||
<img src="lib/images/ui/button-load.gif" id="login-spinner" style="display: none;"> | |||
<img src="images/ui/button-load.gif" id="login-spinner" style="display: none;"> | |||
</div> | |||
<p id="forgot-link"></p> | |||
</div> | |||
@@ -82,9 +82,7 @@ def build_page(page_name): | |||
else: | |||
page_options["page_name"] = page_name | |||
basepath = webnotes.utils.get_base_path() | |||
no_cache = page_options.get("no_cache") | |||
# if generator, then load bean, pass arguments | |||
if page_options.get("page_or_generator")=="Generator": | |||
@@ -107,7 +105,7 @@ def build_page(page_name): | |||
context.update(get_website_settings()) | |||
jenv = webnotes.get_jenv() | |||
context["base_template"] = jenv.get_template(webnotes.get_config().get("base_template")) | |||
context["base_template"] = jenv.get_template("portal/templates/base.html") | |||
template_name = page_options['template_path'] | |||
html = jenv.get_template(template_name).render(context) | |||
@@ -398,8 +398,6 @@ def clear_cache(): | |||
def clear_web(): | |||
import webnotes.webutils | |||
webnotes.connect() | |||
from webnotes.website.doctype.website_sitemap_config.website_sitemap_config import build_website_sitemap_config | |||
build_website_sitemap_config() | |||
webnotes.webutils.clear_cache() | |||
webnotes.destroy() | |||