Browse Source

cms updates

develop
Rushabh Mehta 13 years ago
parent
commit
b9483d1809
  1. 1
      .gitignore
  2. 9
      erpnext/website/doctype/blog/blog.py
  3. 2
      erpnext/website/doctype/blog/blog_page.js
  4. 20
      erpnext/website/doctype/website_settings/website_settings.py
  5. 2
      erpnext/website/page/blog/blog.js
  6. 4
      public/js/all-app.js
  7. 4
      public/js/all-web.js
  8. 1
      public/js/wn-web.js
  9. 17
      public/rss.xml
  10. 3
      public/sitemap.xml

1
.gitignore

@ -8,7 +8,6 @@ version.num
public/*.html public/*.html
!public/blank.html !public/blank.html
!public/unsupported.html !public/unsupported.html
!public/login-page.html
public/js/lib public/js/lib
public/images/lib public/images/lib
public/files public/files

9
erpnext/website/doctype/blog/blog.py

@ -46,8 +46,9 @@ class DocType():
import markdown2 import markdown2
import os import os
from webnotes.utils import global_date_format, get_fullname from webnotes.utils import global_date_format, get_fullname
from webnotes.model.code import get_obj
self.doc.content_html = markdown2.markdown(self.doc.content or '') self.doc.content_html = unicode(markdown2.markdown(self.doc.content or ''))
self.doc.full_name = get_fullname(self.doc.owner) self.doc.full_name = get_fullname(self.doc.owner)
self.doc.updated = global_date_format(self.doc.modified) self.doc.updated = global_date_format(self.doc.modified)
@ -56,14 +57,16 @@ class DocType():
with open(os.path.join(os.path.dirname(__file__), 'blog_page.js'), 'r') as f: with open(os.path.join(os.path.dirname(__file__), 'blog_page.js'), 'r') as f:
p.script = Template(f.read()).render(doc=self.doc) p.script = Template(f.read()).render(doc=self.doc)
p.web_page = 'Yes'
p.save() p.save()
get_obj(doc=p).write_cms_page()
website.utils.add_guest_access_to_page(p.name) website.utils.add_guest_access_to_page(p.name)
self.doc.page_name = p.name self.doc.page_name = p.name
# cleanup # cleanup
for f in ['content_html', 'full_name', 'updated']: for f in ['full_name', 'updated', 'content_html']:
if f in self.doc.fields: if f in self.doc.fields:
del self.doc.fields[f] del self.doc.fields[f]

2
erpnext/website/doctype/blog/blog_page.js

@ -27,7 +27,7 @@ pscript['onload_{{ doc.name }}'] = function(wrapper) {
render_row: function(parent, data) { render_row: function(parent, data) {
console.log(data); console.log(data);
if(data.content && data.content.length==100) data.content += '...'; if(data.content && data.content.length==100) data.content += '...';
parent.innerHTML = repl('<a href="#!%(name)s">%(title)s</a>\ parent.innerHTML = repl('<a href="%(name)s.html">%(title)s</a>\
<div class="comment">%(content)s</div><br>', data); <div class="comment">%(content)s</div><br>', data);
}, },
page_length: 5, page_length: 5,

20
erpnext/website/doctype/website_settings/website_settings.py

@ -34,11 +34,25 @@ class DocType:
def rewrite_pages(self): def rewrite_pages(self):
"""rewrite all web pages""" """rewrite all web pages"""
import webnotes import webnotes
from webnotes.model.doclist import DocList
from webnotes.model.code import get_obj from webnotes.model.code import get_obj
# rewrite all web pages
for name in webnotes.conn.sql("""select name from `tabWeb Page` where docstatus=0"""):
DocList('Web Page', name[0]).save()
# rewrite all blog pages
for name in webnotes.conn.sql("""select name from `tabBlog` where docstatus=0
and ifnull(published,0)=1"""):
DocList('Blog', name[0]).save()
for p in webnotes.conn.sql("""select name from tabPage where docstatus=0 from webnotes.cms.make import make_web_core
and web_page = 'Yes'"""): make_web_core()
get_obj('Page', p[0]).write_cms_page()
get_obj('Page', 'blog').write_cms_page(force=True)
webnotes.msgprint('Rebuilt all blogs and pages')
def set_home_page(self): def set_home_page(self):

2
erpnext/website/page/blog/blog.js

@ -33,7 +33,7 @@ pscript.onload_blog = function(wrapper) {
parent.innerHTML = repl('<h2>%(title)s</h2>\ parent.innerHTML = repl('<h2>%(title)s</h2>\
<p><div class="help">By %(first_name)s%(last_name)s, %(date)s</div></p>\ <p><div class="help">By %(first_name)s%(last_name)s, %(date)s</div></p>\
<p>%(content)s</p>\ <p>%(content)s</p>\
<a href="#!%(name)s">Read Full Text</a><br>', data); <a href="%(name)s.html">Read Full Text</a><br>', data);
}, },
page_length: 10 page_length: 10
}); });

4
public/js/all-app.js

@ -137,9 +137,7 @@ wn.provide('wn.settings');wn.provide('wn.ui');
/* /*
* lib/js/wn/versions.js * lib/js/wn/versions.js
*/ */
wn.versions={check:function(){if(window.localStorage){if(window._version_number==-1||parseInt(localStorage._version_number)!=parseInt(window._version_number)){var localversion=localStorage._version_number;localStorage.clear();console.log("Cache cleared - version: "+localversion wn.versions={check:function(){if(window.localStorage){var localversion=localStorage._version_number;localStorage.clear();}}}
+' to '+_version_number)}
localStorage.setItem('_version_number',window._version_number);}}}
/* /*
* lib/js/wn/assets.js * lib/js/wn/assets.js
*/ */

4
public/js/all-web.js

@ -24,9 +24,7 @@ wn.provide('wn.settings');wn.provide('wn.ui');
/* /*
* lib/js/wn/versions.js * lib/js/wn/versions.js
*/ */
wn.versions={check:function(){if(window.localStorage){if(window._version_number==-1||parseInt(localStorage._version_number)!=parseInt(window._version_number)){var localversion=localStorage._version_number;localStorage.clear();console.log("Cache cleared - version: "+localversion wn.versions={check:function(){if(window.localStorage){var localversion=localStorage._version_number;localStorage.clear();}}}
+' to '+_version_number)}
localStorage.setItem('_version_number',window._version_number);}}}
/* /*
* lib/js/wn/assets.js * lib/js/wn/assets.js
*/ */

1
public/js/wn-web.js

@ -1,4 +1,3 @@
window._version_number = "2a070dfb16a80c744b13c7609859086ef91dfd755d70032ee00ee4f6";
window.home_page = "index"; window.home_page = "index";
// footer signup widget // footer signup widget
// automatically adds it to the .layout-main div of the page // automatically adds it to the .layout-main div of the page

17
public/rss.xml

@ -21,7 +21,8 @@ import cgi, cgitb, os, sys
cgitb.enable() cgitb.enable()
# import libs # import libs
sys.path.append('lib/py') sys.path.append('..')
sys.path.append('../lib/py')
import webnotes import webnotes
import webnotes.auth import webnotes.auth
@ -29,7 +30,13 @@ import webnotes.auth
if __name__=='__main__': if __name__=='__main__':
webnotes.http_request = webnotes.auth.HTTPRequest() webnotes.http_request = webnotes.auth.HTTPRequest()
from webnotes.cms import feed from webnotes.cms import feed
xml = feed.generate() try:
print 'Content-Type: text/xml' print 'Content-Type: text/xml'
print print
print xml xml = feed.generate()
print xml
except Exception, e:
print 'Content-Type: text/html'
print
import webnotes.utils
print webnotes.utils.getTraceback()

3
public/sitemap.xml

@ -20,7 +20,8 @@ import cgi, cgitb, os, sys
cgitb.enable() cgitb.enable()
# import libs # import libs
sys.path.append('lib/py') sys.path.append('..')
sys.path.append('../lib/py')
import webnotes import webnotes
import webnotes.auth import webnotes.auth

Loading…
Cancel
Save