From bea9292fc4ef5789538a0c979cfea73dd9e207d4 Mon Sep 17 00:00:00 2001 From: Paul Rodwell Date: Sat, 7 Mar 2015 19:47:31 +0000 Subject: [PATCH] A start at opening the door to support for other languages. --- lib/legacy.coffee | 3 +-- lib/link.coffee | 15 ++++++++------- lib/page.coffee | 2 +- lib/pageHandler.coffee | 4 +++- lib/refresh.coffee | 1 + lib/resolve.coffee | 2 -- 6 files changed, 14 insertions(+), 13 deletions(-) diff --git a/lib/legacy.coffee b/lib/legacy.coffee index 58995cb0..2b1d28ba 100644 --- a/lib/legacy.coffee +++ b/lib/legacy.coffee @@ -74,7 +74,7 @@ $ -> active.set this unless $(e.target).is("a") .delegate '.internal', 'click', (e) -> - name = $(e.target).data 'pageName' + name = $(e.target).text() # ensure that name is a string (using string interpolation) name = "#{name}" pageHandler.context = $(e.target).attr('title').split(' => ') @@ -167,4 +167,3 @@ $ -> state.first() $('.page').each refresh.cycle active.set($('.page').last()) - diff --git a/lib/link.coffee b/lib/link.coffee index b66e646d..dc055dbf 100644 --- a/lib/link.coffee +++ b/lib/link.coffee @@ -8,10 +8,10 @@ active = require './active' refresh = require './refresh' {asSlug, pageEmitter} = require './page' -createPage = (name, loc) -> +createPage = (slug, loc, title=null) -> site = loc if loc and loc isnt 'view' $page = $ """ -
+

#{name}

@@ -19,16 +19,17 @@ createPage = (name, loc) ->
""" $page.data('site', site) if site + $page.data('title', title) if title $page -showPage = (name, loc) -> - createPage(name, loc).appendTo('.main').each refresh.cycle +showPage = (slug, loc, title=null) -> + createPage(slug, loc, title).appendTo('.main').each refresh.cycle doInternalLink = (name, $page, site=null) -> - name = asSlug(name) + slug = asSlug(name) $($page).nextAll().remove() if $page? lineup.removeAllAfterKey $($page).data('key') if $page? - showPage(name,site) + showPage(slug,site,name) active.set($('.page').last()) showResult = (pageObject) -> @@ -41,4 +42,4 @@ pageEmitter.on 'show', (page) -> console.log 'pageEmitter handling', page showResult page -module.exports = {createPage, doInternalLink, showPage, showResult} \ No newline at end of file +module.exports = {createPage, doInternalLink, showPage, showResult} diff --git a/lib/page.coffee b/lib/page.coffee index 9f7bd79f..ab3ac497 100644 --- a/lib/page.coffee +++ b/lib/page.coffee @@ -160,4 +160,4 @@ newPage = (json, site) -> {getRawPage, getContext, isPlugin, isRemote, isLocal, getRemoteSite, getRemoteSiteDetails, getSlug, getNeighbors, getTitle, setTitle, getRevision, getTimestamp, addItem, getItem, addParagraph, seqItems, seqActions, become, siteLineup, merge, apply} -module.exports = {newPage, asSlug, pageEmitter} \ No newline at end of file +module.exports = {newPage, asSlug, pageEmitter} diff --git a/lib/pageHandler.coffee b/lib/pageHandler.coffee index fb5d1373..41d59c4a 100644 --- a/lib/pageHandler.coffee +++ b/lib/pageHandler.coffee @@ -26,7 +26,7 @@ pageFromLocalStorage = (slug)-> undefined recursiveGet = ({pageInformation, whenGotten, whenNotGotten, localContext}) -> - {slug,rev,site} = pageInformation + {slug,rev,site,title} = pageInformation if site localContext = [] @@ -55,6 +55,8 @@ recursiveGet = ({pageInformation, whenGotten, whenNotGotten, localContext}) -> type: 'GET' dataType: 'json' url: url + "?random=#{random.randomBytes(4)}" + data: + 'title': title success: (page) -> page = revision.create rev, page if rev #NEWPAGE server from pageHandler.get diff --git a/lib/refresh.coffee b/lib/refresh.coffee index d1eb398a..60c73b73 100644 --- a/lib/refresh.coffee +++ b/lib/refresh.coffee @@ -286,6 +286,7 @@ cycle = -> slug: slug rev: rev site: $page.data('site') + title: $page.data('title') } createGhostPage = -> diff --git a/lib/resolve.coffee b/lib/resolve.coffee index a4c378d1..6321fff8 100644 --- a/lib/resolve.coffee +++ b/lib/resolve.coffee @@ -55,5 +55,3 @@ resolve.resolveLinks = (string, sanitize=escape) -> .replace /\[((http|https|ftp):.*?) (.*?)\]/gi, external sanitize string .replace /〖(\d+)〗/g, unstash - -