Class: MyMedia::Frontpage
Instance Method Summary collapse
-
#initialize(config: nil, public_type: '', rss: nil, debug: false) ⇒ Frontpage
constructor
A new instance of Frontpage.
- #publish_frontpage(s = 'index.html') ⇒ Object
- #publish_timeline(raw_msg, static_url, target_url = '') ⇒ Object
- #publish_to_lists(record = {}, public_type = nil) ⇒ Object
Constructor Details
#initialize(config: nil, public_type: '', rss: nil, debug: false) ⇒ Frontpage
Returns a new instance of Frontpage.
428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 |
# File 'lib/mymedia.rb', line 428 def initialize(config: nil, public_type: '', rss: nil, debug: false) raise FrontpageException, "no config found" if config.nil? @debug = debug c = SimpleConfig.new(config).to_h @home = c[:home] @www = c[:www] @index_page = c[:index_page] == 'true' @public_type = public_type @rss = rss @sps = c[:sps] @opts = {username: c[:username], password: c[:password]} @schema = 'posts/post(url, title, meta)' @xslt_schema = 'channel[title:title,description:desc]/' + \ 'item(title:title,link:url)' end |
Instance Method Details
#publish_frontpage(s = 'index.html') ⇒ Object
449 450 451 452 453 |
# File 'lib/mymedia.rb', line 449 def publish_frontpage(s='index.html') publish_html(@home + '/' + s) 'frontpage published' end |
#publish_timeline(raw_msg, static_url, target_url = '') ⇒ Object
483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 |
# File 'lib/mymedia.rb', line 483 def publish_timeline(raw_msg, static_url, target_url='') timeline_filepath = File.join(@home, @www, 'timeline', 'dynarex.xml') main_dir = File.join(@home, @www, 'dynarex', 'main-directory.xml') record = Dynarex.new(main_dir).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) ⇒ Object
456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 |
# File 'lib/mymedia.rb', line 456 def publish_to_lists(record={}, public_type=nil) @log.info 'inside publish_to_lists' if @log @public_type = public_type if public_type raw_msg, static_url, target_url = \ record[:title], record[:url], record[:static_url] puts 'vars: ' + [@home, @www, @public_type].inspect if @debug dynarex_filepath = File.join(@home, @www, @public_type, 'dynarex.xml') raw_dynarex_filepath = File.join(@home, @www, 'r', @public_type, 'dynarex.xml') publish_dynarex(dynarex_filepath, record, {rss: @rss || false}) publish_dynarex(raw_dynarex_filepath, record, {rss: @rss || false}) # 26-feb-2023 the following line was disabled because there's a # better alternative to updating a timeline using the noticesys gem. # to-do: Somehow integrate this with the new system. # #publish_timeline(raw_msg, static_url, target_url) (msg: 'publish_to_lists completed') end |