def on_first_run(self): logging.info("Spawning Miro Guide...") guide_url = unicode(app.config.get(prefs.CHANNEL_GUIDE_URL)) if guide.get_guide_by_url(guide_url) is None: allowed_urls = app.config.get(prefs.CHANNEL_GUIDE_ALLOWED_URLS) guide.ChannelGuide(guide_url, unicode(allowed_urls).split()) if self.theme is not None: # we have a theme new_guides = unicode( app.config.get(prefs.ADDITIONAL_CHANNEL_GUIDES)).split() for temp_guide in new_guides: if guide.get_guide_by_url(temp_guide) is None: guide.ChannelGuide(temp_guide) if (((app.config.get(prefs.DEFAULT_CHANNELS_FILE) is not None) and (app.config.get(prefs.THEME_NAME) is not None))): importer = opml.Importer() filepath = resources.theme_path( app.config.get(prefs.THEME_NAME), app.config.get(prefs.DEFAULT_CHANNELS_FILE)) if os.path.exists(filepath): importer.import_subscriptions(filepath, show_summary=False) else: logging.warn("Theme subscription file doesn't exist: %s", filepath) elif None not in self.pastThemes: # We pretend to have run the default theme, and then # install the default channels. XXX: If Miro Guide isn't # installed by the theme and it doesn't provide a default # set of channels, we'll never install the Miro Guide. # This code would install the Miro Guide if it isn't # already installed # if guide.get_guide_by_url(prefs.CHANNEL_GUIDE_URL.default) is None: # guide.ChannelGuide(prefs.CHANNEL_GUIDE_URL.default) self.pastThemes.append(None) self._install_default_feeds() else: # no theme self._install_default_feeds() signals.system.theme_first_run(self.theme)
def on_first_run(self): logging.info("Spawning Miro Guide...") guide_url = unicode(app.config.get(prefs.CHANNEL_GUIDE_URL)) if guide.get_guide_by_url(guide_url) is None: allowed_urls = app.config.get(prefs.CHANNEL_GUIDE_ALLOWED_URLS) guide.ChannelGuide(guide_url, unicode(allowed_urls).split()) if self.theme is not None: # we have a theme new_guides = unicode(app.config.get(prefs.ADDITIONAL_CHANNEL_GUIDES)).split() for temp_guide in new_guides: if guide.get_guide_by_url(temp_guide) is None: guide.ChannelGuide(temp_guide) if (((app.config.get(prefs.DEFAULT_CHANNELS_FILE) is not None) and (app.config.get(prefs.THEME_NAME) is not None))): importer = opml.Importer() filepath = resources.theme_path(app.config.get(prefs.THEME_NAME), app.config.get(prefs.DEFAULT_CHANNELS_FILE)) if os.path.exists(filepath): importer.import_subscriptions(filepath, show_summary=False) else: logging.warn("Theme subscription file doesn't exist: %s", filepath) elif None not in self.pastThemes: # We pretend to have run the default theme, and then # install the default channels. XXX: If Miro Guide isn't # installed by the theme and it doesn't provide a default # set of channels, we'll never install the Miro Guide. # This code would install the Miro Guide if it isn't # already installed # if guide.get_guide_by_url(prefs.CHANNEL_GUIDE_URL.default) is None: # guide.ChannelGuide(prefs.CHANNEL_GUIDE_URL.default) self.pastThemes.append(None) self._install_default_feeds() else: # no theme self._install_default_feeds() signals.system.theme_first_run(self.theme)
def on_theme_change(self): if self.theme is None: # vanilla Miro guide_url = app.config.get(prefs.CHANNEL_GUIDE_URL) if guide.get_guide_by_url(guide_url) is None: # This happens when the DB is initialized with a theme that # doesn't have it's own set of default channels; None is # artificially added to the pastThemes lists to prevent the # default channels from being added again. However, it means # that we need to add the Miro Guide to the DB ourselves. logging.warn('Installing default guide after switch to vanilla Miro') guide.ChannelGuide(guide_url, unicode(app.config.get( prefs.CHANNEL_GUIDE_ALLOWED_URLS)).split()) self.signal_change()
def handle_site(self, site_dict, parent_folder): """ Site subscriptions look like:: { 'type': 'site', 'url': URL of the site 'title': name of the site (optional), } """ assert parent_folder is None, "no folders in site section" url = site_dict["url"] if guide.get_guide_by_url(url) is None: new_guide = guide.ChannelGuide(url, [u"*"]) title = site_dict.get("title") if title is not None and title != url: new_guide.set_title(title) return True else: return False
def handle_site(self, site_dict, parent_folder): """ Site subscriptions look like:: { 'type': 'site', 'url': URL of the site 'title': name of the site (optional), } """ assert parent_folder is None, "no folders in site section" url = site_dict['url'] if guide.get_guide_by_url(url) is None: new_guide = guide.ChannelGuide(url, [u'*']) title = site_dict.get('title') if title is not None and title != url: new_guide.set_title(title) return True else: return False