class MyMedia::Frontpage

Public Class Methods

new(config: nil, public_type: '', rss: nil) click to toggle source
# File lib/mymedia.rb, line 261
def initialize(config: nil, public_type: '', rss: nil)
  
  raise FrontpageException, "no config found" if config.nil?
  
  c = SimpleConfig.new(config).to_h

  @home = c[:home]
  @index_page = c[:index_page] == 'true'
  @public_type = public_type
  @rss = rss
  @sps = c[:sps]
  @opts = {username: c[:username], password: c[:password]}
        
end

Public Instance Methods

publish_frontpage(s='index.html') click to toggle source
# File lib/mymedia.rb, line 276
def publish_frontpage(s='index.html')    

  publish_html(@home + '/' + s) 
  'frontpage published'
end
publish_timeline(raw_msg, static_url, target_url='') click to toggle source
# File lib/mymedia.rb, line 303
def publish_timeline(raw_msg, static_url, target_url='')

  timeline_filepath = "%s/timeline/dynarex.xml" % @home    
  record = Dynarex.new(@home + '/dynarex/main-directory.xml').find_by_title(@public_type)    

  thumbnail, subject_url = record.thumbnail, record.url
  
  content = {
          title: raw_msg, 
            url: static_url,
      thumbnail: thumbnail, 
    subject_url: subject_url, 
        raw_url: target_url 
  }
  
  publish_dynarex(timeline_filepath, content, rss: true)     

end
publish_to_lists(record={}, public_type=nil) click to toggle source
# File lib/mymedia.rb, line 283
def publish_to_lists(record={}, public_type=nil)
  
  @public_type = public_type if public_type

  raw_msg, static_url, target_url = \
      record[:title], record[:url], record[:static_url]

  dynarex_filepath = "%s/%s/dynarex.xml" % [@home, @public_type]
  raw_dynarex_filepath = "%s/r/%s/dynarex.xml" % [@home, @public_type]


  publish_dynarex(dynarex_filepath, record, {rss: @rss || false})    
  publish_dynarex(raw_dynarex_filepath, record, {rss: @rss || false})          

  publish_timeline(raw_msg, static_url, target_url)         
  send_message(msg: 'publish_to_lists completed')
 
end