Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
justincarter committed Oct 15, 2013
0 parents commit 0a645d1
Show file tree
Hide file tree
Showing 15 changed files with 635 additions and 0 deletions.
15 changes: 15 additions & 0 deletions customadmin/customadmin.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<webtop>
<section id="plugins" label="Plugins">
<subsection id="blog" label="Blog">
<menu sequence="1" id="content" label="Content">
<menuitem sequence="1" id="post" label="Blog Posts" typename="blogPost" />
<menuitem sequence="2" id="category" label="Blog Categories" typename="blogCategory" />
</menu>
<menu sequence="2" id="migrate" label="Migrate BlogCFC">
<menuitem sequence="1" id="content" label="Import Content" typename="configBlog" bodyView="webtopImportContentBlogCFC" />
<menuitem sequence="2" id="comments" label="Disqus Comments" typename="configBlog" bodyView="webtopExportCommentsBlogCFC" />
</menu>
</subsection>
</section>
</webtop>
60 changes: 60 additions & 0 deletions packages/forms/configBlog.cfc
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
<cfcomponent displayName="Blog Configuration" extends="farcry.core.packages.forms.forms"
key="blogfc" hint="Configure settings for the Blog plugin">

<cfproperty name="author" type="string" required="false"
ftSeq="1" ftWizardStep="" ftFieldset="General Settings" ftLabel="Author Name"
ftHint="The author name that will appear in the 'by line' of each blog post. Leave blank to hide the author name.">

<cfproperty name="urlStem" type="string" required="false" default="/blog"
ftSeq="2" ftWizardStep="" ftFieldset="General Settings" ftLabel="URL Stem"
ftValidation="required"
ftHint="The URL stem that all blog post and blog category URLs will begin with, including the leading slash. e.g: /blog">

<cfproperty name="numBlogPosts" type="integer" required="false" default="10"
ftSeq="3" ftWizardStep="" ftFieldset="General Settings" ftLabel="Posts per Page"
ftType="integer" ftDefault="10" ftValidation="required number"
ftHint="The number of blog posts to show per page.">

<cfproperty name="disqusShortname" type="string" required="false" default=""
ftSeq="10" ftWizardStep="" ftFieldset="Disqus Comments" ftLabel="Disqus Shortname"
ftType="string"
ftHint="The &quot;shortname&quot; of the site you have created in <a target='_blank' href='http://disqus.com'>Disqus</a> to use for blog comment integration.">


<cfscript>

function ftValidateUrlStem(objectid,typename,stFieldPost,stMetadata) {
var stResult = structNew();
var oField = createObject("component", application.fapi.getPackagePath("formtools","field"));

// url stem must not be empty and must begin with a slash
if (NOT len(arguments.stFieldPost.value)) {
arguments.stFieldPost.value = "/blog";
}
else if (left(arguments.stFieldPost.value, 1) neq "/") {
arguments.stFieldPost.value = "/" & arguments.stFieldPost.value;
}

stResult = oField.passed(value=arguments.stFieldPost.value);
return stResult;
}

function ftValidateNumBlogPosts(objectid,typename,stFieldPost,stMetadata) {
var stResult = structNew();
var oField = createObject("component", application.fapi.getPackagePath("formtools","field"));

// numBlogPosts must be a number greater than 0
if (NOT isNumeric(arguments.stFieldPost.value)) {
arguments.stFieldPost.value = 10;
}
else if (arguments.stFieldPost.value lt 1) {
arguments.stFieldPost.value = 10;
}

stResult = oField.passed(value=arguments.stFieldPost.value);
return stResult;
}

</cfscript>

</cfcomponent>
26 changes: 26 additions & 0 deletions packages/types/blogCategory.cfc
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<cfcomponent displayName="Blog Category" extends="farcry.core.packages.types.types" bFriendly="true">

<cfproperty name="title" type="string" required="false"
ftSeq="1" ftWizardStep="" ftFieldset="" ftLabel="Title">

<cfproperty name="alias" type="string" required="false" default=""
hint="The old friendly URL alias used by BlogCFC">


<cffunction name="getBlogPostsByCategory" returntype="query">
<cfargument name="objectid" required="true" hint="The category objectid used to select the blog posts">

<cfset var qBlogPosts = queryNew("objectid")>

<cfquery name="qBlogPosts" datasource="#application.dsn#">
SELECT objectid
FROM #application.dbowner#blogPost_aCategories
INNER JOIN #application.dbowner#blogPost ON (#application.dbowner#blogPost_aCategories.parentid = #application.dbowner#blogPost.objectid)
WHERE data = <cfqueryparam cfsqltype="cf_sql_varchar" value="#arguments.objectid#">
ORDER BY posteddatetime DESC
</cfquery>

<cfreturn qBlogPosts>
</cffunction>

</cfcomponent>
33 changes: 33 additions & 0 deletions packages/types/blogPost.cfc
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<cfcomponent displayName="Blog Post" extends="farcry.core.packages.types.types"
bFriendly="true" fualias="blog">

<cfproperty name="title" type="string" required="false"
ftSeq="1" ftWizardStep="" ftFieldset="Blog Details" ftLabel="Title">

<cfproperty name="aCategories" type="array" required="false"
ftSeq="2" ftWizardStep="" ftFieldset="Blog Details" ftLabel="Categories"
ftType="typeahead" ftJoin="blogCategory" ftLibraryDataSQLOrderBy="label ASC">

<cfproperty name="posteddatetime" type="date" required="false"
ftSeq="3" ftWizardStep="" ftFieldset="Blog Details" ftLabel="Date Posted"
ftType="datetime" ftDefaultType="Evaluate" ftDefault="now()"
ftDateFormatMask="dd mmm yyyy" ftTimeFormatMask="hh:mm tt"
ftShowTime="true">

<cfproperty name="body" type="longchar" required="false"
ftSeq="4" ftWizardStep="" ftFieldset="Content" ftLabel="Body"
ftType="richtext">

<cfproperty name="aRelated" type="array" required="false"
ftSeq="5" ftWizardStep="" ftFieldset="Relationships" ftLabel="Related Blog Posts"
ftType="array" ftJoin="blogPost" ftLibraryDataSQLOrderBy="posteddatetime DESC">

<cfproperty name="views" type="integer" required="false" default=""
hint="The number of blog entry views from BlogCFC">

<cfproperty name="alias" type="string" required="false" default=""
hint="The old friendly URL alias used by BlogCFC">

<cfproperty name="status" type="string" required="false" default="draft" ftLabel="Status">

</cfcomponent>
18 changes: 18 additions & 0 deletions webskin/blogCategory/displayBody.cfm
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<cfsetting enablecfoutputonly="true">
<!--- @@displayname: Blog Category Body --->
<!--- @@author: Justin Carter ([email protected]) --->

<cfimport taglib="/farcry/core/tags/webskin" prefix="skin">

<cfset qBlogPosts = getBlogPostsByCategory(stObj.objectid)>
<cfset numBlogPosts = application.fapi.getConfig("blogfc", "numBlogPosts")>

<cfoutput>
<cfloop query="qBlogPosts" endrow="#numBlogPosts#">
<section>
<skin:view typename="blogPost" objectid="#qBlogPosts.objectid#" webskin="displayBody" showComments="false" />
</section>
</cfloop>
</cfoutput>

<cfsetting enablecfoutputonly="false">
12 changes: 12 additions & 0 deletions webskin/blogCategory/displaySystemFU.cfm
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<cfsetting enablecfoutputonly="true" showdebugoutput="false">

<cfset stem = application.fapi.getConfig("blogfc", "urlStem")>
<cfset alias = stObj.title>
<cfif len(stObj.alias)>
<cfset alias = stObj.alias>
</cfif>

<!--- return the friendly url --->
<cfoutput>#stem#/#alias#</cfoutput>

<cfsetting enablecfoutputonly="false">
14 changes: 14 additions & 0 deletions webskin/blogCategory/webtopBody.cfm
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<cfsetting enablecfoutputonly="true">
<!--- @@displayname: Blog Category Webtop Body --->

<cfimport taglib="/farcry/core/tags/formtools" prefix="ft">

<ft:objectAdmin
typename="#stObj.name#"
columnList="label"
sortableColumns="label"
lFilterFields="label"
sqlOrderBy="label ASC" />


<cfsetting enablecfoutputonly="false">
43 changes: 43 additions & 0 deletions webskin/blogPost/displayBody.cfm
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<cfsetting enablecfoutputonly="true">
<!--- @@displayname: Blog Body --->
<!--- @@author: Justin Carter ([email protected]) --->

<cfimport taglib="/farcry/core/tags/webskin" prefix="skin">

<cfparam name="stParam.showComments" default="true">

<cfset qCategories = application.fapi.getContentObjects(typename="blogCategory", lProperties="objectid,title", objectid_IN=arrayToList(stObj.aCategories), orderby="label ASC")>
<cfset authorName = application.fapi.getConfig("blogfc", "author")>

<cfoutput>
<h1><a href="#application.fapi.getLink(typename="blogPost", objectid=stObj.objectid)#">#stObj.title#</a></h1>
<p class="blog-byline">
<i class="icon-time icon-fixed-width"></i> #lsDateFormat(stObj.posteddatetime, "d mmmm yyyy")# #lsTimeFormat(stObj.posteddatetime, "h:mm tt")#
<cfif len(authorName)>
by #authorName#<br>
</cfif>
<cfif qCategories.recordCount>
<i class="icon-tag icon-fixed-width"></i>
<cfloop query="qCategories">
<a href="#application.fapi.getLink(typename="blogCategory", objectid=qCategories.objectid)#">#qCategories.title#</a>
<cfif qCategories.currentrow neq qCategories.recordCount>&middot;</cfif>
</cfloop>
<br>
</cfif>
<cfif len(application.fapi.getConfig("blogfc", "disqusShortname"))>
<i class="icon-comments icon-fixed-width"></i> <a href="#application.fapi.getLink(typename="blogPost", objectid=stObj.objectid)###disqus_thread" data-disqus-identifier="#stObj.objectid#">Comments</a>
</cfif>
</p>
<div class="content blog-content">
<cfif structKeyExists(stObj, "body") AND len(stObj.body)>
#stObj.body#
</cfif>
</div>
<cfif stParam.showComments>
<div class="blog-comments">
<skin:view stObject="#stObj#" webskin="displayComments" />
</div>
</cfif>
</cfoutput>

<cfsetting enablecfoutputonly="false">
27 changes: 27 additions & 0 deletions webskin/blogPost/displayComments.cfm
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<cfsetting enablecfoutputonly="true">
<!--- @@displayname: Blog Comments --->
<!--- @@author: Justin Carter ([email protected]) --->

<cfimport taglib="/farcry/core/tags/webskin" prefix="skin">

<cfset oEnv = application.fapi.getContentType(typename="configEnvironment")>

<cfif len(application.fapi.getConfig("blogfc", "disqusShortname"))>
<cfoutput>
<div id="disqus_thread"></div>
<script type="text/javascript">
var disqus_shortname = '#application.fapi.getConfig("blogfc", "disqusShortname")#';
var disqus_identifier = '#stObj.objectid#';
var disqus_title = '#stObj.title#';
var disqus_url = '#oEnv.getCanonicalURL()##application.fapi.getLink(type=stObj.typename, objectid=stObj.objectid)#';
(function() {
var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
dsq.src = '//' + disqus_shortname + '.disqus.com/embed.js';
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
})();
</script>
</cfoutput>
</cfif>

<cfsetting enablecfoutputonly="false">
59 changes: 59 additions & 0 deletions webskin/blogPost/displayPageRSS.cfm
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
<cfsetting enablecfoutputonly="true">
<!--- @@displayname: Blog RSS Feed --->
<!--- @@author: Justin Carter ([email protected]) --->
<!--- @@viewstack: data --->
<!--- @@mimetype: application/rss+xml --->
<!--- @@fualias: rss --->

<cfimport taglib="/farcry/core/tags/webskin" prefix="skin">

<cfparam name="url.catid" default="">

<cfset oEnv = application.fapi.getContentType(typename="configEnvironment")>
<cfset qBlogPosts = application.fapi.getContentObjects(typename="blogPost", orderby="posteddatetime DESC")>

<cfset dateMask = "ddd, dd mmm yyyy">
<cfset timeMask = "HH:mm:ss">
<cfset maxrows = 25>
<cfset count = 1>

<cfoutput>
<rss version="2.0">
<channel>
<title>#xmlFormat(application.fapi.getConfig("general", "sitetitle"))#</title>
<link>#xmlFormat(oEnv.getCanonicalURL() & application.fapi.getConfig("blogfc", "urlStem"))#</link>
<description/>
<language>en-us</language>
<pubDate>#xmlFormat(dateFormat(dateConvert("local2utc", now()), dateMask) & " " & timeFormat(dateConvert("local2utc", now()), timeMask))# +0000</pubDate>
<lastBuildDate>#xmlFormat(dateFormat(dateConvert("local2utc", now()), dateMask) & " " & timeFormat(dateConvert("local2utc", now()), timeMask))# +0000</lastBuildDate>
<generator>FarCry Blog</generator>
<docs>http://blogs.law.harvard.edu/tech/rss</docs>
<managingEditor>#xmlFormat(application.fapi.getConfig("general", "adminemail"))#</managingEditor>
<webMaster>#xmlFormat(application.fapi.getConfig("general", "adminemail"))#</webMaster>
<cfloop query="qBlogPosts">
<cfset stBlogPost = application.fapi.getContentObject(typename="blogPost", objectid=qBlogPosts.objectid)>
<cfif NOT len(url.catid) OR arrayFindNoCase(stBlogPost.aCategories, url.catid)>
<cfset qCategories = application.fapi.getContentObjects(typename="blogCategory", lProperties="objectid,title", objectid_IN=arrayToList(stBlogPost.aCategories), orderby="label ASC")>

<item>
<title>#xmlFormat(stBlogPost.title)#</title>
<link>#xmlFormat(oEnv.getCanonicalURL() & application.fapi.getLink(type="blogPost", objectid=stBlogPost.objectid))#</link>
<description>#xmlFormat(stBlogPost.body)#</description>
<cfloop query="qCategories">
<category>#xmlFormat(qCategories.title)#</category>
</cfloop>
<pubDate>#xmlFormat(dateFormat(dateConvert("local2utc", stBlogPost.posteddatetime), dateMask) & " " & timeFormat(dateConvert("local2utc", stBlogPost.posteddatetime), timeMask))# +0000</pubDate>
<guid>#xmlFormat(oEnv.getCanonicalURL() & application.fapi.getLink(type="blogPost", objectid=stBlogPost.objectid))#</guid>
</item>

<cfset count = count + 1>
</cfif>
<cfif count gt maxrows>
<cfbreak>
</cfif>
</cfloop>
</channel>
</rss>
</cfoutput>

<cfsetting enablecfoutputonly="false">
15 changes: 15 additions & 0 deletions webskin/blogPost/displaySystemFU.cfm
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<cfsetting enablecfoutputonly="true" showdebugoutput="false">

<cfset stem = application.fapi.getConfig("blogfc", "urlStem")>
<cfset year = datepart("yyyy", stObj.posteddatetime)>
<cfset month = datepart("m", stObj.posteddatetime)>
<cfset day = datepart("d", stObj.posteddatetime)>
<cfset alias = stObj.title>
<cfif len(stObj.alias)>
<cfset alias = stObj.alias>
</cfif>

<!--- return the friendly url --->
<cfoutput>#stem#/#year#/#month#/#day#/#alias#</cfoutput>

<cfsetting enablecfoutputonly="false">
18 changes: 18 additions & 0 deletions webskin/blogPost/displayTypeBody.cfm
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<cfsetting enablecfoutputonly="true">
<!--- @@displayname: Blog Post Type Body --->
<!--- @@author: Justin Carter ([email protected]) --->

<cfimport taglib="/farcry/core/tags/webskin" prefix="skin">

<cfset qBlogPosts = application.fapi.getContentObjects(typename="blogPost", orderby="posteddatetime DESC")>
<cfset numBlogPosts = application.fapi.getConfig("blogfc", "numBlogPosts")>

<cfoutput>
<cfloop query="qBlogPosts" endrow="#numBlogPosts#">
<section>
<skin:view typename="blogPost" objectid="#qBlogPosts.objectid#" webskin="displayBody" showComments="false" />
</section>
</cfloop>
</cfoutput>

<cfsetting enablecfoutputonly="false">
14 changes: 14 additions & 0 deletions webskin/blogPost/webtopBody.cfm
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<cfsetting enablecfoutputonly="true">
<!--- @@displayname: Default Webtop Body --->

<cfimport taglib="/farcry/core/tags/formtools" prefix="ft">

<ft:objectAdmin
typename="#stObj.name#"
columnList="label,status,posteddatetime,datetimelastupdated"
sortableColumns="label,status,posteddatetime,datetimelastupdated"
lFilterFields="label"
sqlOrderBy="posteddatetime DESC" />


<cfsetting enablecfoutputonly="false">
Loading

0 comments on commit 0a645d1

Please sign in to comment.