Skip to content

Commit

Permalink
finishing off rss feature, cleaning html better, moving to a place wh…
Browse files Browse the repository at this point in the history
…ere it is served as text, not binary
  • Loading branch information
houshuang committed Sep 28, 2011
1 parent 7483d93 commit a4c9bc0
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 5 deletions.
Binary file added .DS_Store
Binary file not shown.
2 changes: 1 addition & 1 deletion bibtex-batch.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def make_rss_feed
end
end

File.write(Wiki_path + "/data/media/pages.xml", content)
File.write(Wiki_path + "/feed.xml", content)
end

make_rss_feed
Expand Down
19 changes: 15 additions & 4 deletions dokuwiki.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,13 @@ def curtitle
#### keyboard commands ####

# adds the currently selected page to RSS feed, adds data to a temp file, will be formatted next time bibtex-batch
# is executed
# is executed (Ctrl+Alt+Cmd+F)
def add_to_rss
require 'open-uri'
fname = Wiki_path + "/rss-temp"
internalurl = cururl.split("/").last

# load existing holding file, or start form scratch
if File.exists?(fname)
rss_entries = Marshal::load(File.read(fname))
else
Expand All @@ -34,14 +35,24 @@ def add_to_rss
page_contents = open("http://localhost/wiki/#{internalurl}?vecdo=print").read
contents = page_contents.scan(/<\!\-\- start rendered wiki content \-\-\>(.+?)\<\!\-\- end rendered wiki content \-\-\>/m)[0][0]

contents.gsub!(/\<div class\=\"hiddenGlobal(.+?)\<div class\=\"plugin_include_content/m, '<div ')
puts contents
contents.gsub!(/\<div class\=\"hiddenGlobal(.+?)\<div class\=\"plugin_include_content/m, '<div ') # remove pure bibtex
contents.gsub!(/\<span class\=\"tip\"\>(.+?)\<\/span\>/, '') # remove citation tooltips
# remove wiki clippings
contents.gsub!(/\<div class\=\"plugin\_include\_content\ plugin\_include\_\_clip(.+?)\<\/div\>/m, '')
contents.gsub!(/\<div class\=\"plugin\_include\_content\ plugin\_include\_\_kindle(.+?)\<\/div\>/m, '')

# remove title (already given in metadata)
contents.sub!(/\<h1 class\=\"sectionedit1\"\>(.+?)\<\/a\>\<\/h1\>/, '')

contents.gsub!(/\<\!\-\- TOC START \-\-\>(.+?)\<\!\-\- TOC END \-\-\>/m, '')


title = page_contents.scan(/\<h1(.+?)id(.+?)>(.+)\<(.+?)\<\/h1\>/)[0][2]
rss_entries << {:title => title, :date => Time.now, :link => "#{Internet_path}/#{internalurl}", :description => contents}

rss_entries = rss_entries.drop(1) if rss_entries.size > 10
File.write(fname, Marshal::dump(rss_entries))
growl("\"#{title}\" added to RSS feed")
growl("Article added to feed", "'#{title}' added to RSS feed")
end

# pops up dialogue box, asking where to send text, takes selected text (or just link, if desired) and inserts at the bottom
Expand Down
1 change: 1 addition & 0 deletions wikilite.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/bin/bash
rm -rf /wiki/data/cache/*
rsync --delete -avzPe ssh /Library/WebServer/Documents/wiki/data [email protected]:~/public_html/wiki
rsync --delete -avzPe ssh /Library/WebServer/Documents/wiki/feed.xml [email protected]:~/public_html/wiki/
rsync --delete -avzPe ssh /Library/WebServer/Documents/wiki/lib/plugins/dokuresearchr/json.tmp [email protected]:~/public_html/wiki/lib/plugins/dokuresearchr/
ssh [email protected] 'chmod -R 755 ~/public_html/wiki/data/*; chmod 755 ~/public_html/wiki/data;touch ~/public_html/wiki/conf/local.php'

0 comments on commit a4c9bc0

Please sign in to comment.