Skip to content

Commit 2236f1f

Browse files
committed
v0.67
1 parent 424c986 commit 2236f1f

File tree

7 files changed

+372
-270
lines changed

7 files changed

+372
-270
lines changed

editor/scripts.js

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
1-
//See this blog post for info on replacing this code.
2-
//http://myword.smallpict.com/2015/04/02/towardEditorPlugins.html
3-
function getEditorText (s) {
4-
return ($("#idTextArea").val ());
5-
}
6-
function setEditorText (s) {
7-
$("#idTextArea").val (s);
8-
}
9-
function initEditor () {
10-
var placeholder = "Obviously this is a good place to write something.";
11-
$("#idEditorContainer").append ('<textarea class="myTextArea" id="idTextArea" onKeyUp="keyupTextArea ()" placeholder="' + placeholder + '"></textarea>');
12-
}
13-
1+
//stuff for plain editor
2+
function getEditorText (s) {
3+
return ($("#idTextArea").val ());
4+
}
5+
function setEditorText (s) {
6+
$("#idTextArea").val (s);
7+
}
8+
function initEditor () {
9+
var placeholder = "Obviously this is a good place to write something.";
10+
$("#idEditorContainer").append ('<textarea class="myTextArea" id="idTextArea" onKeyUp="keyupTextArea ()" placeholder="' + placeholder + '"></textarea>');
11+
}

index.html

Lines changed: 44 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,18 @@
2828

2929
<script src="http://api.nodestorage.io/api.js"></script>
3030

31+
<link rel="stylesheet" href="http://fargo.io/code/editors/mediumeditor/dist/css/medium-editor.css">
32+
<link rel="stylesheet" href="http://fargo.io/code/editors/mediumeditor/dist/css/themes/default.css">
33+
<script src="http://fargo.io/code/editors/mediumeditor/dist/js/medium-editor.js"></script>
34+
35+
<script src="http://fargo.io/code/keypress.js" /></script>
36+
3137
<script src="scripts.js"></script>
3238
<link href="styles.css" rel="stylesheet" type="text/css">
33-
<script src="editor/scripts.js"></script>
39+
40+
<link href='http://fonts.googleapis.com/css?family=Open+Sans:400,800' rel='stylesheet' type='text/css'>
41+
<link href='http://fonts.googleapis.com/css?family=Merriweather:400,700,700italic,400italic' rel='stylesheet' type='text/css'>
42+
3443
</head>
3544
<body>
3645
<div class="divMenubar" id="idMenubar">
@@ -43,16 +52,24 @@
4352
<div class="container">
4453
<a class="brand" href="/"><span id="idMenuProductName"></span></a>
4554
<ul class="nav" id="idMainMenuList">
46-
55+
<li class="dropdown" id="idPublishMenu">
56+
<a href="#" class="dropdown-toggle" data-toggle="dropdown">Publish&nbsp;<b class="caret"></b></a>
57+
<ul class="dropdown-menu">
58+
<li><a onclick="publishButtonClick ();"><span class="menuKeystroke">Cmd-P</span>Publish...</a></li>
59+
<li><a onclick="publishAllPosts ();">Publish all...</a></li>
60+
<li class="divider"></li>
61+
<li><a onclick="viewPublishedFile ();">View story...</a></li>
62+
</ul>
63+
</li>
4764
<li class="dropdown" id="idEditorMenu">
4865
<a href="#" class="dropdown-toggle" data-toggle="dropdown">Editor&nbsp;<b class="caret"></b></a>
4966
<ul class="dropdown-menu">
50-
<li><a onclick="viewPublishedFile ();">View published file...</a></li>
67+
<li><a onclick="newButtonClick ();">New story...</a></li>
68+
<li class="divider"></li>
69+
<li><a onclick="setBackgroundImage ();">Set background image...</a></li>
5170
<li><a onclick="viewFeed ();">View RSS feed...</a></li>
5271
<li><a onclick="getPostsInJson ();">Get JSON backup...</a></li>
5372
<li class="divider"></li>
54-
<li><a onclick="publishAllPosts ();">Publish all posts...</a></li>
55-
<li class="divider"></li>
5673
<li><a onclick="switchServer ();">Switch server...</a></li>
5774
</ul>
5875
</li>
@@ -91,17 +108,6 @@
91108
</div>
92109
</div>
93110
</div>
94-
<div class="divFileOpenDialog">
95-
<div id="idFileOpenDialog" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="attEditorLabel" aria-hidden="true">
96-
<div class="modal-body">
97-
<div id="idWhereToDisplayFileList">
98-
</div>
99-
</div>
100-
<div class="modal-footer">
101-
<a href="#" class="btn btn-primary" onclick="closeFileOpenDialog ();">Close</a>
102-
</div>
103-
</div>
104-
</div>
105111
<div class="divPrefsDialog" comment="This is the Settings dialog.">
106112
<div id="idPrefsDialog" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="windowTitleLabel" aria-hidden="true">
107113
<div class="modal-body">
@@ -110,35 +116,41 @@
110116
<div class="divTabsFromOutline">
111117
<div class="tabbable">
112118
<ul class="nav nav-tabs" data-tabs="tabs">
113-
<li class="active" ><a href="#idYou51" data-toggle="tab">You</a></li>
114-
<li><a href="#idFeed51" data-toggle="tab">Feed</a></li>
115-
<li><a href="#idImage51" data-toggle="tab">Image</a></li>
116-
<li><a href="#idCms51" data-toggle="tab">CMS</a></li>
119+
<li class="active" ><a href="#idYou290" data-toggle="tab">You</a></li>
120+
<li><a href="#idFeed290" data-toggle="tab">Feed</a></li>
121+
<li><a href="#idImage290" data-toggle="tab">Image</a></li>
122+
<li><a href="#idCms290" data-toggle="tab">CMS</a></li>
123+
<li><a href="#idPublish290" data-toggle="tab">Publish</a></li>
117124
</ul>
118125
<div id="my-tab-content" class="tab-content">
119-
<div class="active tab-pane" id="idYou51">
126+
<div class="active tab-pane" id="idYou290">
120127
<fieldset>
121128
<div class="divPrefs"> <div class="clearfix"> <label for="authorName">Name:</label> <div class="input"> <input class="xlarge prefsInput" id="authorName" name="authorName" size="50" type="text" value="" placeholder="Your name." /> </div> </div><div class="clearfix"> <label for="authorWebsite">Website:</label> <div class="input"> <input class="xlarge prefsInput" id="authorWebsite" name="authorWebsite" size="50" type="text" value="" placeholder="Your website." /> </div> </div> </div>
122129
</fieldset>
123130
</div>
124-
<div class="tab-pane" id="idFeed51">
131+
<div class="tab-pane" id="idFeed290">
125132
<fieldset>
126133
<div class="divPrefs"> <p>You can set the title, link and description for the RSS feed that Radio3 maintains.</p><div class="clearfix"> <label for="rssTitle">Title:</label> <div class="input"> <input class="xlarge prefsInput" id="rssTitle" name="rssTitle" size="50" type="text" value="" placeholder="The &lt;title> element for the feed." /> </div> </div><div class="clearfix"> <label for="rssLink">Link:</label> <div class="input"> <input class="xlarge prefsInput" id="rssLink" name="rssLink" size="50" type="text" value="" placeholder="The &lt;link> element for the feed." /> </div> </div><div class="clearfix"> <label for="rssDescription">Description:</label> <div class="input"> <textarea class="xxlarge" id="rssDescription" name="rssDescription" cols="70" rows="3"placeholder="The &lt;description> element for the feed." ></textarea> </div> </div> </div>
127134
</fieldset>
128135
</div>
129-
<div class="tab-pane" id="idImage51">
136+
<div class="tab-pane" id="idImage290">
130137
<fieldset>
131138
<div class="divPrefs"> <div class="clearfix"> <label for="flUseDefaultImage"></label> <div class="input"> <input type="checkbox" name="flUseDefaultImage" value=xxx>&nbsp;Use default image if no image is specified. </div> </div><div class="clearfix"> <label for="defaultImageUrl">URL:</label> <div class="input"> <input class="xlarge prefsInput" id="defaultImageUrl" name="defaultImageUrl" size="50" type="text" value="" placeholder="We'll use this image for essays where no image is specified." /> </div> </div> </div>
132139
</fieldset>
133140
</div>
134-
<div class="tab-pane" id="idCms51">
141+
<div class="tab-pane" id="idCms290">
135142
<fieldset>
136143
<div class="divPrefs"> <div class="clearfix"> <label for="nameDefaultTemplate">Template name:</label> <div class="input"> <input class="xlarge prefsInput" id="nameDefaultTemplate" name="nameDefaultTemplate" size="50" type="text" value="" placeholder="The name of the template to use for new essays." /> </div> </div><div class="clearfix"> <label for="flDisqusComments"></label> <div class="input"> <input type="checkbox" name="flDisqusComments" value=xxx>&nbsp;Include Disqus comments on your pages? </div> </div><div class="clearfix"> <label for="disqusGroupName">Group name:</label> <div class="input"> <input class="xlarge prefsInput" id="disqusGroupName" name="disqusGroupName" size="50" type="text" value="" placeholder="The name of your Disqus comment group." /> </div> </div> </div>
137144
</fieldset>
138145
</div>
146+
<div class="tab-pane" id="idPublish290">
147+
<fieldset>
148+
<div class="divPrefs"> <div class="clearfix"> <label for="flMarkdownProcess"></label> <div class="input"> <input type="checkbox" name="flMarkdownProcess" value=xxx>&nbsp;Use the Markdown processor. </div> </div><div class="clearfix"> <label for="flAutoPublish"></label> <div class="input"> <input type="checkbox" name="flAutoPublish" value=xxx>&nbsp;Automatically publish the current story when it's saved. </div> </div> </div>
149+
</fieldset>
150+
</div>
151+
</div>
152+
</div>
139153
</div>
140-
</div>
141-
</div>
142154

143155
</form>
144156

@@ -152,43 +164,12 @@
152164
</div>
153165
<div class="divPageBody">
154166
<div class="divWholePageMessage" id="idEditor" style="display: none;">
155-
<form class="form-horizontal">
156-
<div class="control-group">
157-
<label class="control-label" for="idTitle">Title:</label>
158-
<div class="controls">
159-
<input type="text" id="idTitle" class="myInputItem" placeholder="Appears in the title area of the page.">
160-
</div>
161-
</div>
162-
<div class="control-group">
163-
<label class="control-label" for="idDescription">Description:</label>
164-
<div class="controls">
165-
<textarea class="myDescriptionArea" id="idDescription" placeholder="Appears in smaller type below the title."></textarea>
166-
</div>
167-
</div>
168-
<div class="control-group">
169-
<label class="control-label" for="idImageUrl">Image URL:</label>
170-
<div class="controls">
171-
<div class="divTemplateMenu" id="idTemplateMenu">
172-
<select id="idTemplateSelect" onchange="templateMenuSelect ();">
173-
</select>
174-
</div>
175-
<input type="text" id="idImageUrl" class="xlarge myInputItem imageUrlItem" placeholder="Background image of the title area of the page.">
176-
</div>
177-
</div>
178-
<div class="control-group">
179-
<label class="control-label" for="idTextArea">Body:</label>
180-
<div class="controls">
181-
<div class="divEditorContainer" id="idEditorContainer">
182-
</div>
183-
184-
<button id="idNewButton" class="btn btn-large btnNew" type="button" onclick="newButtonClick ();">New</button>
185-
<button id="idPublishButton" class="btn btn-large btnPublish" type="button" onclick="publishButtonClick ();">Publish</button>
186-
187-
<div class="divPublishedUrl" id="idPublishedUrl">
188-
</div>
189-
</div>
190-
</div>
191-
</form>
167+
<div class="divTitleEditor" id="idTitleEditor">
168+
</div>
169+
<div class="divDescriptionEditor" id="idDescriptionEditor">
170+
</div>
171+
<div class="divBodyEditor" id="idBodyEditor">
172+
</div>
192173
</div>
193174
<div class="divWholePageMessage" id="idLogonMessage" style="display: none;">
194175
<div class="divLogonMessage">

lib/utils.js

Lines changed: 41 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,9 @@ function stringContains (s, whatItMightContain, flUnicase) { //11/9/14 by DW
115115
return (s.indexOf (whatItMightContain) != -1);
116116
}
117117
function beginsWith (s, possibleBeginning, flUnicase) {
118+
if (s === undefined) { //7/15/15 by DW
119+
return (false);
120+
}
118121
if (s.length == 0) { //1/1/14 by DW
119122
return (false);
120123
}
@@ -332,16 +335,33 @@ function random (lower, upper) {
332335
function removeMultipleBlanks (s) { //7/30/14 by DW
333336
return (s.toString().replace (/ +/g, " "));
334337
}
338+
function jsonStringify (jstruct, flFixBreakage) { //7/30/14 by DW
339+
//Changes
340+
//6/16/15; 10:43:25 AM by DW
341+
//Andrew Shell reported an issue in the encoding of JSON that's solved by doing character replacement.
342+
//However, this is too big a change to make for all the code that calls this library routine, so we added a boolean flag, flFixBreakage.
343+
//If this proves to be harmless, we'll change the default to true.
344+
//http://river4.smallpict.com/2015/06/16/jsonEncodingIssueSolved.html
345+
if (flFixBreakage === undefined) {
346+
flFixBreakage = false;
347+
}
348+
var s = JSON.stringify (jstruct, undefined, 4);
349+
if (flFixBreakage) {
350+
s = s.replace (/\u2028/g,'\\u2028').replace (/\u2029/g,'\\u2029');
351+
}
352+
return (s);
353+
}
335354
function stringAddCommas (x) { //5/27/14 by DW
336355
return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
337356
}
338-
function readHttpFile (url, callback, timeoutInMilliseconds) { //5/27/14 by DW
357+
function readHttpFile (url, callback, timeoutInMilliseconds, headers) { //5/27/14 by DW xxx
339358
if (timeoutInMilliseconds === undefined) {
340359
timeoutInMilliseconds = 30000;
341360
}
342361
var jxhr = $.ajax ({
343362
url: url,
344-
dataType: "text" ,
363+
dataType: "text",
364+
headers: headers,
345365
timeout: timeoutInMilliseconds
346366
})
347367
.success (function (data, status) {
@@ -353,7 +373,7 @@ function readHttpFile (url, callback, timeoutInMilliseconds) { //5/27/14 by DW
353373
});
354374
}
355375
function readHttpFileThruProxy (url, type, callback) { //10/25/14 by DW
356-
var urlReadFileApi = "http://pub.fargo.io/httpReadUrl";
376+
var urlReadFileApi = "http://pub2.fargo.io:5347/httpReadUrl";
357377
if (type === undefined) {
358378
type = "text/plain";
359379
}
@@ -389,6 +409,14 @@ function stringPopLastField (s, chdelim) { //5/28/14 by DW
389409
}
390410
return (s);
391411
}
412+
function stringPopExtension (s) { //4/29/15 by DW
413+
for (var i = s.length - 1; i >= 0; i--) {
414+
if (s [i] == ".") {
415+
return (stringMid (s, 1, i));
416+
}
417+
}
418+
return (s);
419+
}
392420
function filledString (ch, ct) { //6/4/14 by DW
393421
var s = "";
394422
for (var i = 0; i < ct; i++) {
@@ -438,21 +466,18 @@ function hotUpText (s, url) { //7/18/14 by DW
438466
s = leftpart + linktext + rightpart;
439467
return (s);
440468
}
469+
function getDomainFromUrl (url) { //7/11/15 by DW
470+
if ((url != null ) && (url != "")) {
471+
url = url.replace("www.","").replace("www2.", "").replace("feedproxy.", "").replace("feeds.", "");
472+
var root = url.split('?')[0]; // cleans urls of form http://domain.com?a=1&b=2
473+
url = root.split('/')[2];
474+
}
475+
return (url);
476+
};
441477
function getFavicon (url) { //7/18/14 by DW
442-
function getDomain (url) {
443-
if ((url != null ) && (url != "")) {
444-
url = url.replace("www.","").replace("www2.", "").replace("feedproxy.", "").replace("feeds.", "");
445-
var root = url.split('?')[0]; // cleans urls of form http://domain.com?a=1&b=2
446-
var url = root.split('/')[2];
447-
}
448-
return (url);
449-
};
450-
var domain = getDomain (url);
478+
var domain = getDomainFromUrl (url);
451479
return ("http://www.google.com/s2/favicons?domain=" + domain);
452480
};
453-
function jsonStringify (jstruct) { //7/19/14 by DW
454-
return (JSON.stringify (jstruct, undefined, 4));
455-
}
456481
function getURLParameter (name) { //7/21/14 by DW
457482
return (decodeURI ((RegExp(name + '=' + '(.+?)(&|$)').exec(location.search)||[,null])[1]));
458483
}
@@ -497,7 +522,7 @@ function innerCaseName (text) { //8/12/14 by DW
497522
return (s);
498523
}
499524
function hitCounter (counterGroup, counterServer) { //8/12/14 by DW
500-
var defaultCounterGroup = "scripting", defaultCounterServer = "http://counter.fargo.io/counter";
525+
var defaultCounterGroup = "scripting", defaultCounterServer = "http://counter2.fargo.io:5337/counter";
501526
var thispageurl = location.href;
502527
if (counterGroup === undefined) {
503528
counterGroup = defaultCounterGroup;

0 commit comments

Comments
 (0)