mirror of
https://github.com/frappe/erpnext.git
synced 2026-06-02 03:39:11 +00:00
added blogger, updated style and blogs
This commit is contained in:
@@ -1,9 +1,4 @@
|
|||||||
div.outer {
|
div.outer {
|
||||||
-moz-box-shadow: 0px 0px 3px rgba(0,0,0,0.9);
|
|
||||||
-webkit-box-shadow: 0px 0px 3px rgba(0,0,0,0.9);
|
|
||||||
box-shadow: 0px 0px 3px rgba(0,0,0,0.9);
|
|
||||||
background-color: #fff;
|
|
||||||
border-radius: 5px;
|
|
||||||
padding: 30px;
|
padding: 30px;
|
||||||
margin: 30px -30px 10px -30px;
|
margin: 30px -30px 10px -30px;
|
||||||
min-height: 400px;
|
min-height: 400px;
|
||||||
@@ -24,6 +19,8 @@ footer {
|
|||||||
border: 0px;
|
border: 0px;
|
||||||
border-bottom: 1px solid #ddd;
|
border-bottom: 1px solid #ddd;
|
||||||
border-radius: 0px;
|
border-radius: 0px;
|
||||||
|
padding-right: 30px;
|
||||||
|
padding-left: 30px;
|
||||||
}
|
}
|
||||||
|
|
||||||
p, li {
|
p, li {
|
||||||
@@ -98,6 +95,18 @@ p, li {
|
|||||||
width: 30px;
|
width: 30px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.avatar-medium {
|
||||||
|
margin-right: 5px;
|
||||||
|
width: 48px;
|
||||||
|
height: 48px;
|
||||||
|
border-radius: 48px;
|
||||||
|
-moz-border-radius: 48px;
|
||||||
|
-webkit-border-radius: 48px;
|
||||||
|
}
|
||||||
|
.avatar-medium img {
|
||||||
|
width: 48px;
|
||||||
|
}
|
||||||
|
|
||||||
.avatar-large {
|
.avatar-large {
|
||||||
margin-right: 10px;
|
margin-right: 10px;
|
||||||
width: 72px;
|
width: 72px;
|
||||||
|
|||||||
@@ -27,6 +27,9 @@ class DocType:
|
|||||||
from website.utils import page_name
|
from website.utils import page_name
|
||||||
self.doc.name = page_name(self.doc.title)
|
self.doc.name = page_name(self.doc.title)
|
||||||
|
|
||||||
|
def validate(self):
|
||||||
|
self.doc.blog_intro = self.doc.blog_intro[:140]
|
||||||
|
|
||||||
def on_update(self):
|
def on_update(self):
|
||||||
from website.utils import update_page_name
|
from website.utils import update_page_name
|
||||||
update_page_name(self.doc, self.doc.title)
|
update_page_name(self.doc, self.doc.title)
|
||||||
@@ -66,6 +69,10 @@ class DocType:
|
|||||||
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.creation)
|
self.doc.updated = global_date_format(self.doc.creation)
|
||||||
self.doc.content_html = self.doc.content
|
self.doc.content_html = self.doc.content
|
||||||
|
if self.doc.blogger:
|
||||||
|
self.doc.blogger_info = webnotes.doc("blogger", self.doc.blogger).fields
|
||||||
|
if self.doc.blogger_info.avatar and not "/" in self.doc.blogger_info.avatar:
|
||||||
|
self.doc.blogger_info.avatar = "files/" + self.doc.blogger_info.avatar
|
||||||
|
|
||||||
comment_list = webnotes.conn.sql("""\
|
comment_list = webnotes.conn.sql("""\
|
||||||
select comment, comment_by_fullname, creation
|
select comment, comment_by_fullname, creation
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
{
|
{
|
||||||
"creation": "2013-01-25 11:35:09",
|
"creation": "2013-01-25 11:35:09",
|
||||||
"docstatus": 0,
|
"docstatus": 0,
|
||||||
"modified": "2013-02-21 16:54:04",
|
"modified": "2013-03-07 16:32:13",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"owner": "Administrator"
|
"owner": "Administrator"
|
||||||
},
|
},
|
||||||
@@ -50,18 +50,37 @@
|
|||||||
"label": "Published"
|
"label": "Published"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"description": "Description for listing page, in plain text, only a couple of lines.",
|
"doctype": "DocField",
|
||||||
|
"fieldname": "column_break_3",
|
||||||
|
"fieldtype": "Column Break"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"doctype": "DocField",
|
||||||
|
"fieldname": "blogger",
|
||||||
|
"fieldtype": "Link",
|
||||||
|
"label": "Blogger",
|
||||||
|
"options": "Blogger",
|
||||||
|
"reqd": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"doctype": "DocField",
|
||||||
|
"fieldname": "section_break_5",
|
||||||
|
"fieldtype": "Section Break"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"description": "Description for listing page, in plain text, only a couple of lines. (max 140 characters)",
|
||||||
"doctype": "DocField",
|
"doctype": "DocField",
|
||||||
"fieldname": "blog_intro",
|
"fieldname": "blog_intro",
|
||||||
"fieldtype": "Small Text",
|
"fieldtype": "Small Text",
|
||||||
"label": "Blog Intro"
|
"label": "Blog Intro",
|
||||||
|
"reqd": 1
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"doctype": "DocField",
|
"doctype": "DocField",
|
||||||
"fieldname": "content",
|
"fieldname": "content",
|
||||||
"fieldtype": "Text Editor",
|
"fieldtype": "Text Editor",
|
||||||
"label": "Content",
|
"label": "Content",
|
||||||
"reqd": 0
|
"reqd": 1
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"doctype": "DocField",
|
"doctype": "DocField",
|
||||||
|
|||||||
0
website/doctype/blogger/__init__.py
Normal file
0
website/doctype/blogger/__init__.py
Normal file
18
website/doctype/blogger/blogger.py
Normal file
18
website/doctype/blogger/blogger.py
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
# For license information, please see license.txt
|
||||||
|
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
import webnotes
|
||||||
|
|
||||||
|
class DocType:
|
||||||
|
def __init__(self, d, dl):
|
||||||
|
self.doc, self.doclist = d, dl
|
||||||
|
|
||||||
|
def on_update(self):
|
||||||
|
"if profile is set, then update all older blogs"
|
||||||
|
if self.doc.profile:
|
||||||
|
for blog in webnotes.conn.sql_list("""select name from tabBlog where owner=%s
|
||||||
|
and ifnull(blogger,'')=''""", self.doc.profile):
|
||||||
|
b = webnotes.bean("Blog", blog)
|
||||||
|
b.blogger = self.doc.name
|
||||||
|
b.save()
|
||||||
|
|
||||||
95
website/doctype/blogger/blogger.txt
Normal file
95
website/doctype/blogger/blogger.txt
Normal file
@@ -0,0 +1,95 @@
|
|||||||
|
[
|
||||||
|
{
|
||||||
|
"creation": "2013-03-07 16:28:19",
|
||||||
|
"docstatus": 0,
|
||||||
|
"modified": "2013-03-07 16:33:37",
|
||||||
|
"modified_by": "Administrator",
|
||||||
|
"owner": "Administrator"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"allow_attach": 1,
|
||||||
|
"autoname": "field:short_name",
|
||||||
|
"description": "Profile of a Blogger",
|
||||||
|
"doctype": "DocType",
|
||||||
|
"document_type": "Master",
|
||||||
|
"max_attachments": 1,
|
||||||
|
"module": "Website",
|
||||||
|
"name": "__common__"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"doctype": "DocField",
|
||||||
|
"name": "__common__",
|
||||||
|
"parent": "Blogger",
|
||||||
|
"parentfield": "fields",
|
||||||
|
"parenttype": "DocType",
|
||||||
|
"permlevel": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"doctype": "DocPerm",
|
||||||
|
"name": "__common__",
|
||||||
|
"parent": "Blogger",
|
||||||
|
"parentfield": "permissions",
|
||||||
|
"parenttype": "DocType",
|
||||||
|
"permlevel": 0,
|
||||||
|
"read": 1,
|
||||||
|
"write": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"doctype": "DocType",
|
||||||
|
"name": "Blogger"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"description": "Will be used in url (usually first name).",
|
||||||
|
"doctype": "DocField",
|
||||||
|
"fieldname": "short_name",
|
||||||
|
"fieldtype": "Data",
|
||||||
|
"label": "Short Name",
|
||||||
|
"reqd": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"doctype": "DocField",
|
||||||
|
"fieldname": "full_name",
|
||||||
|
"fieldtype": "Data",
|
||||||
|
"label": "Full Name",
|
||||||
|
"reqd": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"doctype": "DocField",
|
||||||
|
"fieldname": "profile",
|
||||||
|
"fieldtype": "Link",
|
||||||
|
"label": "Profile",
|
||||||
|
"options": "Profile"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"doctype": "DocField",
|
||||||
|
"fieldname": "bio",
|
||||||
|
"fieldtype": "Small Text",
|
||||||
|
"label": "Bio"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"doctype": "DocField",
|
||||||
|
"fieldname": "avatar",
|
||||||
|
"fieldtype": "Select",
|
||||||
|
"label": "Avatar",
|
||||||
|
"options": "attach_files:"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"doctype": "DocField",
|
||||||
|
"fieldname": "file_list",
|
||||||
|
"fieldtype": "Text",
|
||||||
|
"hidden": 1,
|
||||||
|
"label": "File List",
|
||||||
|
"no_copy": 1,
|
||||||
|
"print_hide": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"create": 1,
|
||||||
|
"doctype": "DocPerm",
|
||||||
|
"role": "Website Manager"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"doctype": "DocPerm",
|
||||||
|
"match": "owner:profile",
|
||||||
|
"role": "Blogger"
|
||||||
|
}
|
||||||
|
]
|
||||||
@@ -1,3 +1,7 @@
|
|||||||
|
{% if doc.at_import %}
|
||||||
|
{{ doc.at_import }}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
body {
|
body {
|
||||||
{% if doc.background_image %}
|
{% if doc.background_image %}
|
||||||
background: url("../files/{{ doc.background_image }}") repeat;
|
background: url("../files/{{ doc.background_image }}") repeat;
|
||||||
@@ -7,8 +11,8 @@ body {
|
|||||||
{% else %}
|
{% else %}
|
||||||
background-color: #edede7;
|
background-color: #edede7;
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if doc.font %}
|
{% if doc.font or doc.google_web_font_for_text %}
|
||||||
font-family: '{{ doc.font }}', Verdana, Sans !important;
|
font-family: '{{ doc.google_web_font_for_text or doc.font }}', Verdana, Sans !important;
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if doc.font_size %}
|
{% if doc.font_size %}
|
||||||
font-size: {{ doc.font_size }} !important;
|
font-size: {{ doc.font_size }} !important;
|
||||||
@@ -21,14 +25,32 @@ body {
|
|||||||
}
|
}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{% if doc.heading_font %}
|
div.outer {
|
||||||
|
background-color: #{{ doc.page_background or "fff" }};
|
||||||
|
}
|
||||||
|
|
||||||
|
{% if doc.google_web_font_for_heading or doc.heading_font %}
|
||||||
h1, h2, h3, h4, h5 {
|
h1, h2, h3, h4, h5 {
|
||||||
font-family: '{{ doc.heading_font}}', Arial, 'Helvetica Neue' !important;
|
font-family: '{{ doc.google_web_font_for_heading or doc.heading_font }}', Arial, 'Helvetica Neue' !important;
|
||||||
|
}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
{% if doc.page_border %}
|
||||||
|
/* Page Border*/
|
||||||
|
div.outer {
|
||||||
|
-moz-box-shadow: 0px 0px 3px rgba(0,0,0,0.9);
|
||||||
|
-webkit-box-shadow: 0px 0px 3px rgba(0,0,0,0.9);
|
||||||
|
box-shadow: 0px 0px 3px rgba(0,0,0,0.9);
|
||||||
|
border-radius: 5px;
|
||||||
|
}
|
||||||
|
{% else %}
|
||||||
|
div.web-footer {
|
||||||
|
border-top: 1px solid #eee;
|
||||||
|
padding-top: 10px;
|
||||||
}
|
}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
/* Bootstrap Navbar */
|
/* Bootstrap Navbar */
|
||||||
|
|
||||||
.navbar-inverse .navbar-inner {
|
.navbar-inverse .navbar-inner {
|
||||||
background-color: #{{ doc.top_bar_background or "444"}};
|
background-color: #{{ doc.top_bar_background or "444"}};
|
||||||
background-repeat: repeat-x;
|
background-repeat: repeat-x;
|
||||||
|
|||||||
@@ -18,6 +18,7 @@
|
|||||||
cur_frm.cscript.onload_post_render = function() {
|
cur_frm.cscript.onload_post_render = function() {
|
||||||
wn.require('lib/public/js/lib/jscolor/jscolor.js');
|
wn.require('lib/public/js/lib/jscolor/jscolor.js');
|
||||||
cur_frm.fields_dict.background_color.input.className = 'color';
|
cur_frm.fields_dict.background_color.input.className = 'color';
|
||||||
|
cur_frm.fields_dict.page_background.input.className = 'color';
|
||||||
cur_frm.fields_dict.top_bar_background.input.className = 'color';
|
cur_frm.fields_dict.top_bar_background.input.className = 'color';
|
||||||
jscolor.bind();
|
jscolor.bind();
|
||||||
}
|
}
|
||||||
@@ -29,10 +29,7 @@ class DocType:
|
|||||||
'custom_template.css'), 'r') as f:
|
'custom_template.css'), 'r') as f:
|
||||||
temp = Template(f.read())
|
temp = Template(f.read())
|
||||||
|
|
||||||
if not self.doc.font_size:
|
self.prepare()
|
||||||
self.doc.font_size = '13px'
|
|
||||||
|
|
||||||
self.doc.small_font_size = str(int(self.doc.font_size[:-2])-2) + 'px'
|
|
||||||
|
|
||||||
self.doc.custom_css = temp.render(doc = self.doc)
|
self.doc.custom_css = temp.render(doc = self.doc)
|
||||||
if self.doc.add_css:
|
if self.doc.add_css:
|
||||||
@@ -41,7 +38,30 @@ class DocType:
|
|||||||
from webnotes.sessions import clear_cache
|
from webnotes.sessions import clear_cache
|
||||||
clear_cache('Guest')
|
clear_cache('Guest')
|
||||||
|
|
||||||
del self.doc.fields['small_font_size']
|
for f in ["small_font_size", "at_import"]:
|
||||||
|
if f in self.doc.fields:
|
||||||
|
del self.doc.fields[f]
|
||||||
|
|
||||||
|
def prepare(self):
|
||||||
|
if not self.doc.font_size:
|
||||||
|
self.doc.font_size = '13px'
|
||||||
|
|
||||||
|
self.doc.small_font_size = str(int(self.doc.font_size[:-2])-2) + 'px'
|
||||||
|
self.doc.page_border = int(self.doc.page_border)
|
||||||
|
|
||||||
|
fonts = []
|
||||||
|
if self.doc.google_web_font_for_heading:
|
||||||
|
fonts.append(self.doc.google_web_font_for_heading)
|
||||||
|
if self.doc.google_web_font_for_text:
|
||||||
|
fonts.append(self.doc.google_web_font_for_text)
|
||||||
|
|
||||||
|
fonts = list(set(fonts))
|
||||||
|
|
||||||
|
self.doc.at_import = ""
|
||||||
|
for f in fonts:
|
||||||
|
self.doc.at_import += "\n@import url(http://fonts.googleapis.com/css?family=%s);" % f.replace(" ", "+")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def on_update(self):
|
def on_update(self):
|
||||||
"""rebuild pages"""
|
"""rebuild pages"""
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
{
|
{
|
||||||
"creation": "2013-01-25 11:35:10",
|
"creation": "2013-01-25 11:35:10",
|
||||||
"docstatus": 0,
|
"docstatus": 0,
|
||||||
"modified": "2013-03-07 14:46:51",
|
"modified": "2013-03-07 16:06:22",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"owner": "Administrator"
|
"owner": "Administrator"
|
||||||
},
|
},
|
||||||
@@ -38,6 +38,12 @@
|
|||||||
"doctype": "DocType",
|
"doctype": "DocType",
|
||||||
"name": "Style Settings"
|
"name": "Style Settings"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"doctype": "DocField",
|
||||||
|
"fieldname": "color",
|
||||||
|
"fieldtype": "Section Break",
|
||||||
|
"label": "Color"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"description": "If image is selected, color will be ignored (attach first)",
|
"description": "If image is selected, color will be ignored (attach first)",
|
||||||
"doctype": "DocField",
|
"doctype": "DocField",
|
||||||
@@ -53,6 +59,25 @@
|
|||||||
"fieldtype": "Data",
|
"fieldtype": "Data",
|
||||||
"label": "Background Color"
|
"label": "Background Color"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"doctype": "DocField",
|
||||||
|
"fieldname": "page_background",
|
||||||
|
"fieldtype": "Data",
|
||||||
|
"label": "Page Background"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"doctype": "DocField",
|
||||||
|
"fieldname": "page_border",
|
||||||
|
"fieldtype": "Check",
|
||||||
|
"label": "Page Border"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"doctype": "DocField",
|
||||||
|
"fieldname": "cb0",
|
||||||
|
"fieldtype": "Column Break",
|
||||||
|
"print_width": "50%",
|
||||||
|
"width": "50%"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"doctype": "DocField",
|
"doctype": "DocField",
|
||||||
"fieldname": "top_bar_background",
|
"fieldname": "top_bar_background",
|
||||||
@@ -69,31 +94,49 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"doctype": "DocField",
|
"doctype": "DocField",
|
||||||
"fieldname": "cb0",
|
"fieldname": "fonts",
|
||||||
"fieldtype": "Column Break",
|
"fieldtype": "Section Break",
|
||||||
"print_width": "50%",
|
"label": "Fonts"
|
||||||
"width": "50%"
|
},
|
||||||
|
{
|
||||||
|
"doctype": "DocField",
|
||||||
|
"fieldname": "heading_font",
|
||||||
|
"fieldtype": "Select",
|
||||||
|
"label": "Font (Heading)",
|
||||||
|
"options": "\nHelvetica Neue\nLucida Grande\nVerdana\nArial\nGeorgia\nTahoma\nLato\nOpen Sans"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"doctype": "DocField",
|
"doctype": "DocField",
|
||||||
"fieldname": "font",
|
"fieldname": "font",
|
||||||
"fieldtype": "Select",
|
"fieldtype": "Select",
|
||||||
"label": "Font",
|
"label": "Font (Text)",
|
||||||
"options": "\nHelvetica Neue\nLucida Grande\nVerdana\nArial\nGeorgia\nTahoma"
|
"options": "\nHelvetica Neue\nLucida Grande\nVerdana\nArial\nGeorgia\nTahoma"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"doctype": "DocField",
|
"doctype": "DocField",
|
||||||
"fieldname": "font_size",
|
"fieldname": "font_size",
|
||||||
"fieldtype": "Select",
|
"fieldtype": "Select",
|
||||||
"label": "Font Size",
|
"label": "Font Size (Text)",
|
||||||
"options": "\n12px\n13px\n14px\n15px\n16px"
|
"options": "\n12px\n13px\n14px\n15px\n16px"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"doctype": "DocField",
|
"doctype": "DocField",
|
||||||
"fieldname": "heading_font",
|
"fieldname": "column_break_13",
|
||||||
"fieldtype": "Select",
|
"fieldtype": "Column Break"
|
||||||
"label": "Heading Font",
|
},
|
||||||
"options": "\nHelvetica Neue\nLucida Grande\nVerdana\nArial\nGeorgia\nTahoma\nLato\nOpen Sans"
|
{
|
||||||
|
"description": "Add the name of Google Web Font e.g. \"Open Sans\"",
|
||||||
|
"doctype": "DocField",
|
||||||
|
"fieldname": "google_web_font_for_heading",
|
||||||
|
"fieldtype": "Data",
|
||||||
|
"label": "Google Web Font (Heading)"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"description": "Add the name of Google Web Font e.g. \"Open Sans\"",
|
||||||
|
"doctype": "DocField",
|
||||||
|
"fieldname": "google_web_font_for_text",
|
||||||
|
"fieldtype": "Data",
|
||||||
|
"label": "Google Web Font (Text)"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"doctype": "DocField",
|
"doctype": "DocField",
|
||||||
|
|||||||
@@ -6,38 +6,38 @@ import webnotes
|
|||||||
import website.utils
|
import website.utils
|
||||||
|
|
||||||
@webnotes.whitelist(allow_guest=True)
|
@webnotes.whitelist(allow_guest=True)
|
||||||
def get_blog_list(args=None):
|
def get_blog_list(start=0, by=None):
|
||||||
"""
|
|
||||||
args = {
|
|
||||||
'start': 0,
|
|
||||||
}
|
|
||||||
"""
|
|
||||||
import webnotes
|
import webnotes
|
||||||
|
condition = ""
|
||||||
if not args: args = webnotes.form_dict
|
if by:
|
||||||
|
condition = " and t1.blogger='%s'" % by.replace("'", "\'")
|
||||||
query = """\
|
query = """\
|
||||||
select
|
select
|
||||||
name, page_name, content, owner, creation as creation,
|
t1.title, t1.name, t1.page_name, t1.creation as creation,
|
||||||
title, (select count(name) from `tabComment` where
|
ifnull(t1.blog_intro, t1.content) as content,
|
||||||
comment_doctype='Blog' and comment_docname=`tabBlog`.name) as comments
|
t2.full_name, t2.avatar, t1.blogger,
|
||||||
from `tabBlog`
|
(select count(name) from `tabComment` where
|
||||||
where ifnull(published,0)=1
|
comment_doctype='Blog' and comment_docname=t1.name) as comments
|
||||||
|
from `tabBlog` t1, `tabBlogger` t2
|
||||||
|
where ifnull(t1.published,0)=1
|
||||||
|
and t1.blogger = t2.name
|
||||||
|
%(condition)s
|
||||||
order by creation desc, name asc
|
order by creation desc, name asc
|
||||||
limit %s, 5""" % args.start
|
limit %(start)s, 5""" % {"start": start, "condition": condition}
|
||||||
|
|
||||||
result = webnotes.conn.sql(query, args, as_dict=1)
|
result = webnotes.conn.sql(query, as_dict=1)
|
||||||
|
|
||||||
# strip html tags from content
|
# strip html tags from content
|
||||||
import webnotes.utils
|
import webnotes.utils
|
||||||
|
|
||||||
for res in result:
|
for res in result:
|
||||||
from webnotes.utils import global_date_format, get_fullname
|
from webnotes.utils import global_date_format, get_fullname
|
||||||
res['full_name'] = get_fullname(res['owner'])
|
|
||||||
res['published'] = global_date_format(res['creation'])
|
res['published'] = global_date_format(res['creation'])
|
||||||
if not res['content']:
|
if not res['content']:
|
||||||
res['content'] = website.utils.get_html(res['page_name'])
|
res['content'] = website.utils.get_html(res['page_name'])
|
||||||
res['content'] = split_blog_content(res['content'])
|
res['content'] = res['content'][:140]
|
||||||
|
if res.avatar and not "/" in res.avatar:
|
||||||
|
res.avatar = "files/" + res.avatar
|
||||||
|
|
||||||
return result
|
return result
|
||||||
|
|
||||||
@@ -116,9 +116,3 @@ def get_blog_content(blog_page_name):
|
|||||||
content = webnotes.utils.escape_html(content)
|
content = webnotes.utils.escape_html(content)
|
||||||
return content
|
return content
|
||||||
|
|
||||||
def split_blog_content(content):
|
|
||||||
content = content.split("<!-- begin blog content -->")
|
|
||||||
content = len(content) > 1 and content[1] or content[0]
|
|
||||||
content = content.split("<!-- end blog content -->")
|
|
||||||
content = content[0]
|
|
||||||
return content
|
|
||||||
@@ -21,6 +21,11 @@ wn.module_page["Website"] = [
|
|||||||
description: wn._("Embed image slideshows in website pages."),
|
description: wn._("Embed image slideshows in website pages."),
|
||||||
doctype:"Website Slideshow"
|
doctype:"Website Slideshow"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
label: wn._("Blogger"),
|
||||||
|
description: wn._("Profile of a blog writer."),
|
||||||
|
doctype:"Blogger"
|
||||||
|
},
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -13,17 +13,33 @@
|
|||||||
<h2>{{ title }}</h2>
|
<h2>{{ title }}</h2>
|
||||||
|
|
||||||
<!-- begin blog content -->
|
<!-- begin blog content -->
|
||||||
<div class="help">By {{ full_name }} on {{ updated }}</div>
|
<div class="help" style="color: #aaa">
|
||||||
|
{{ blogger_info and blogger_info.full_name or full_name }} wrote this on {{ updated }}</div>
|
||||||
<br>
|
<br>
|
||||||
{{ content_html }}
|
{{ content_html }}
|
||||||
<!-- end blog content -->
|
<!-- end blog content -->
|
||||||
|
{% if blogger_info %}
|
||||||
|
<hr />
|
||||||
|
<div class="row">
|
||||||
|
<div class="span2">
|
||||||
|
<div class="avatar avatar-large">
|
||||||
|
<img src="{{ blogger_info.avatar }}" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="span10">
|
||||||
|
<h4>{{ blogger_info.full_name }}</h4>
|
||||||
|
<p>{{ blogger_info.bio }}</p>
|
||||||
|
<p><a href="blog?by={{ blogger_info.name }}&by_name={{ blogger_info.full_name }}">
|
||||||
|
All posts by {{ blogger_info.full_name }}</a></p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
<hr>
|
<hr>
|
||||||
<h3>Comments</h3><br>
|
<h3>Comments</h3><br>
|
||||||
<div class="blog-comments">
|
<div class="blog-comments">
|
||||||
|
|
||||||
{% if not comment_list %}
|
{% if not comment_list %}
|
||||||
<div class="alert no-comment">
|
<div class="no-comment">
|
||||||
<p>Be the first one to comment</p>
|
<p>Be the first one to comment</p>
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
@@ -32,22 +48,19 @@
|
|||||||
</div>
|
</div>
|
||||||
<div><button class="btn add-comment">Add Comment</button></div>
|
<div><button class="btn add-comment">Add Comment</button></div>
|
||||||
<div style="display: none; margin-top: 10px;"
|
<div style="display: none; margin-top: 10px;"
|
||||||
id="comment-form" class="well">
|
id="comment-form">
|
||||||
<div class="alert" style="display:none;"></div>
|
<div class="alert" style="display:none;"></div>
|
||||||
<form>
|
<form>
|
||||||
<p>
|
<fieldset>
|
||||||
<input name="comment_by_fullname" placeholder="Your Name" />
|
<input name="comment_by_fullname" placeholder="Your Name" type="text"/><br>
|
||||||
</p>
|
<input name="comment_by" placeholder="Your Email Id" type="text"/><br>
|
||||||
<p>
|
|
||||||
<input name="comment_by" placeholder="Your Email Id" />
|
|
||||||
</p>
|
|
||||||
<p>
|
|
||||||
<textarea name="comment" placeholder="Comment" style="width: 300px; height: 120px;"/>
|
<textarea name="comment" placeholder="Comment" style="width: 300px; height: 120px;"/>
|
||||||
</textarea>
|
</textarea><br>
|
||||||
</p>
|
|
||||||
<p>
|
|
||||||
<button class="btn btn-info" id="submit-comment">Submit</button>
|
<button class="btn btn-info" id="submit-comment">Submit</button>
|
||||||
|
</fieldset>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
<hr>
|
||||||
|
<a href="blog">Show posts by everyone</p>
|
||||||
</div>
|
</div>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
@@ -10,7 +10,7 @@
|
|||||||
<div class="container">
|
<div class="container">
|
||||||
<div class="outer">
|
<div class="outer">
|
||||||
<div class="navbar{% if top_bar_background=="Black" %} navbar-inverse{% endif %}"
|
<div class="navbar{% if top_bar_background=="Black" %} navbar-inverse{% endif %}"
|
||||||
style="margin-bottom: 0px;">
|
style="">
|
||||||
<div class="navbar-inner">
|
<div class="navbar-inner">
|
||||||
<a class="brand" href="index">{{ brand_html }}</a>
|
<a class="brand" href="index">{{ brand_html }}</a>
|
||||||
<div class="container">
|
<div class="container">
|
||||||
|
|||||||
@@ -23,6 +23,11 @@ $(document).ready(function() {
|
|||||||
$("#next-page").click(function() {
|
$("#next-page").click(function() {
|
||||||
blog.get_list();
|
blog.get_list();
|
||||||
})
|
})
|
||||||
|
|
||||||
|
if(get_url_arg("by_name")) {
|
||||||
|
$("#blog-title").html("Posts by " + get_url_arg("by_name"));
|
||||||
|
$("#blog-link").toggle(true);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
var blog = {
|
var blog = {
|
||||||
@@ -33,10 +38,12 @@ var blog = {
|
|||||||
url: "server.py",
|
url: "server.py",
|
||||||
data: {
|
data: {
|
||||||
cmd: "website.helpers.blog.get_blog_list",
|
cmd: "website.helpers.blog.get_blog_list",
|
||||||
start: blog.start
|
start: blog.start,
|
||||||
|
by: get_url_arg("by")
|
||||||
},
|
},
|
||||||
dataType: "json",
|
dataType: "json",
|
||||||
success: function(data) {
|
success: function(data) {
|
||||||
|
if(data.exc) console.log(data.exc);
|
||||||
blog.render(data.message);
|
blog.render(data.message);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -53,11 +60,20 @@ var blog = {
|
|||||||
b.comment_text = b.comments + ' comments.'
|
b.comment_text = b.comments + ' comments.'
|
||||||
}
|
}
|
||||||
|
|
||||||
$(repl('<h2><a href="%(page_name)s">%(title)s</a></h2>\
|
$(repl('<div class="row">\
|
||||||
<div class="help">%(comment_text)s</div>\
|
<div class="span1">\
|
||||||
%(content)s<br />\
|
<div class="avatar avatar-medium" style="margin-top: 6px;">\
|
||||||
<p><a href="%(page_name)s">Read with comments...</a></p>\
|
<img src="%(avatar)s" />\
|
||||||
<hr /><br />', b)).appendTo($wrap);
|
</div>\
|
||||||
|
</div>\
|
||||||
|
<div class="span11">\
|
||||||
|
<h4><a href="%(page_name)s">%(title)s</a></h4>\
|
||||||
|
<p>%(content)s</p>\
|
||||||
|
<p style="color: #aaa; font-size: 90%">\
|
||||||
|
<a href="blog?by=%(blogger)s&by_name=%(full_name)s">\
|
||||||
|
%(full_name)s</a> wrote this on %(published)s / %(comment_text)s</p>\
|
||||||
|
</div>\
|
||||||
|
</div><hr>', b)).appendTo($wrap);
|
||||||
});
|
});
|
||||||
blog.start += (data.length || 0);
|
blog.start += (data.length || 0);
|
||||||
if(!data.length) {
|
if(!data.length) {
|
||||||
|
|||||||
@@ -12,7 +12,8 @@
|
|||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<div class="span12">
|
<div class="span12">
|
||||||
<h1>Blog</h1>
|
<h2 id="blog-title">Blog</h2>
|
||||||
|
<p id="blog-link" style="display:none"><a href="blog">Show posts by everyone.</a></p>
|
||||||
<br>
|
<br>
|
||||||
<div id="blog-list">
|
<div id="blog-list">
|
||||||
<!-- blog list will be generated dynamically -->
|
<!-- blog list will be generated dynamically -->
|
||||||
|
|||||||
Reference in New Issue
Block a user