Skip to content

Commit

Permalink
cms updates
Browse files Browse the repository at this point in the history
  • Loading branch information
rmehta committed May 9, 2012
1 parent 458ca8e commit b9483d1
Show file tree
Hide file tree
Showing 10 changed files with 41 additions and 22 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ version.num
public/*.html
!public/blank.html
!public/unsupported.html
!public/login-page.html
public/js/lib
public/images/lib
public/files
Expand Down
9 changes: 6 additions & 3 deletions erpnext/website/doctype/blog/blog.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,9 @@ def validate(self):
import markdown2
import os
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.updated = global_date_format(self.doc.modified)

Expand All @@ -56,14 +57,16 @@ def validate(self):

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.web_page = 'Yes'
p.save()
get_obj(doc=p).write_cms_page()

website.utils.add_guest_access_to_page(p.name)
self.doc.page_name = p.name

# cleanup
for f in ['content_html', 'full_name', 'updated']:
for f in ['full_name', 'updated', 'content_html']:
if f in self.doc.fields:
del self.doc.fields[f]

Expand Down
2 changes: 1 addition & 1 deletion erpnext/website/doctype/blog/blog_page.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ pscript['onload_{{ doc.name }}'] = function(wrapper) {
render_row: function(parent, data) {
console.log(data);
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);
},
page_length: 5,
Expand Down
20 changes: 17 additions & 3 deletions erpnext/website/doctype/website_settings/website_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,25 @@ def validate(self):
def rewrite_pages(self):
"""rewrite all web pages"""
import webnotes
from webnotes.model.doclist import DocList
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
and web_page = 'Yes'"""):
get_obj('Page', p[0]).write_cms_page()
from webnotes.cms.make import make_web_core
make_web_core()

get_obj('Page', 'blog').write_cms_page(force=True)

webnotes.msgprint('Rebuilt all blogs and pages')


def set_home_page(self):

Expand Down
2 changes: 1 addition & 1 deletion erpnext/website/page/blog/blog.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ pscript.onload_blog = function(wrapper) {
parent.innerHTML = repl('<h2>%(title)s</h2>\
<p><div class="help">By %(first_name)s%(last_name)s, %(date)s</div></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
});
Expand Down
4 changes: 1 addition & 3 deletions public/js/all-app.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 1 addition & 3 deletions public/js/all-web.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion public/js/wn-web.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
window._version_number = "2a070dfb16a80c744b13c7609859086ef91dfd755d70032ee00ee4f6";
window.home_page = "index";
// footer signup widget
// automatically adds it to the .layout-main div of the page
Expand Down
17 changes: 12 additions & 5 deletions public/rss.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,22 @@ import cgi, cgitb, os, sys
cgitb.enable()

# import libs
sys.path.append('lib/py')
sys.path.append('..')
sys.path.append('../lib/py')

import webnotes
import webnotes.auth

if __name__=='__main__':
webnotes.http_request = webnotes.auth.HTTPRequest()
from webnotes.cms import feed
xml = feed.generate()
print 'Content-Type: text/xml'
print
print xml
try:
print 'Content-Type: text/xml'
print
xml = feed.generate()
print xml
except Exception, e:
print 'Content-Type: text/html'
print
import webnotes.utils
print webnotes.utils.getTraceback()
3 changes: 2 additions & 1 deletion public/sitemap.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ import cgi, cgitb, os, sys
cgitb.enable()

# import libs
sys.path.append('lib/py')
sys.path.append('..')
sys.path.append('../lib/py')

import webnotes
import webnotes.auth
Expand Down

0 comments on commit b9483d1

Please sign in to comment.