Module: Droom

Defined in:
lib/droom/folders.rb,
lib/droom.rb,
lib/droom/engine.rb,
lib/droom/version.rb,
lib/droom/lazy_hash.rb,
app/models/droom/tag.rb,
app/models/droom/page.rb,
app/models/droom/user.rb,
lib/droom/taggability.rb,
lib/droom/user_config.rb,
app/models/droom/event.rb,
app/models/droom/group.rb,
app/models/droom/scrap.rb,
app/models/droom/venue.rb,
lib/droom/dav_resource.rb,
app/models/droom/folder.rb,
app/models/droom/person.rb,
lib/droom/model_helpers.rb,
app/models/droom/tagging.rb,
app/models/droom/calendar.rb,
app/models/droom/category.rb,
app/models/droom/document.rb,
app/models/droom/event_set.rb,
app/models/droom/invitation.rb,
app/models/droom/membership.rb,
app/models/droom/preference.rb,
app/models/droom/organisation.rb,
app/helpers/droom/droom_helper.rb,
app/models/droom/dropbox_token.rb,
app/models/droom/agenda_category.rb,
app/models/droom/personal_folder.rb,
app/models/droom/recurrence_rule.rb,
app/models/droom/dropbox_document.rb,
app/models/droom/group_invitation.rb,
app/models/droom/document_attachment.rb,
app/models/droom/user_action_observer.rb,
app/controllers/droom/pages_controller.rb,
app/controllers/droom/users_controller.rb,
app/controllers/droom/engine_controller.rb,
app/controllers/droom/events_controller.rb,
app/controllers/droom/groups_controller.rb,
app/controllers/droom/people_controller.rb,
app/controllers/droom/scraps_controller.rb,
app/controllers/droom/venues_controller.rb,
app/controllers/droom/folders_controller.rb,
app/controllers/droom/youtube_controller.rb,
app/models/droom/mailing_list_membership.rb,
app/controllers/droom/calendars_controller.rb,
app/controllers/droom/dashboard_controller.rb,
app/controllers/droom/documents_controller.rb,
lib/generators/droom/views/views_generator.rb,
app/controllers/droom/invitations_controller.rb,
app/controllers/droom/memberships_controller.rb,
app/controllers/droom/preferences_controller.rb,
app/controllers/droom/suggestions_controller.rb,
app/controllers/droom/organisations_controller.rb,
lib/generators/droom/install/install_generator.rb,
app/controllers/droom/dropbox_tokens_controller.rb,
app/controllers/droom/agenda_categories_controller.rb,
app/controllers/droom/group_invitations_controller.rb,
lib/generators/droom/dashboard/dashboard_generator.rb,
app/controllers/droom/user_confirmations_controller.rb

Overview

This class has the awkward job of giving access to the mailing list membership records stored in legacy mailman mysql tables. They’re likely to be held in another database, and they have an extremely un-rails-like schema, so our main job is to translate between their and our conventions.

This whole mechanism and its configuration requirements can safely be ignored unless you want to use it, in which case you should set ‘Droom.enable_mailing_lists` to true in an initializer and read on.

If you don’t set ‘enable_mailing_lists` then some database activity will still go on, but with no consequence, and the mailing list interface controls will not appear.

Requirements

The MailingListMembership class is able to interface directly with your existing mailman data, with the addition of a couple of columns to support activerecord associations. It’s mostly just a case of configuring access to the old data.

### Mailman data held in MySQL tables with the ‘flat’ data structure

There are two options here. Either you can use the standard table that has already been created here, or you can define a ‘mailman_` connection in database.yml that points to an external mailman database. In that case see the notes below about adding a couple of columns.

### Mailman configured to use MySQL

If you don’t have an existing mailmanmysql setup, it takes a few steps to point your mailman installation at this database and table. It can be done either globally or on a per-list basis, so it is possible to keep your existing mailman installation but add a new database-backed mailing list.

Mysql storage is considered modern and a bit racy in the mailman community, having only been available since the early 2000s. It’s not officially supported until mailman 3 coalesces out of the ether but if you speak any python it’s easy to make it work with 2.x. Two sets of dusty patches are available here:

http://wiki.list.org/pages/viewpage.action?pageId=15564884

and I’ve found the slightly less ancient version from rezo.net works well:

http://trac.rezo.net/trac/rezo/browser/Mailman

In order that we can store membership of different lists in the same table, please make sure that mailman is using the ‘flat’ data structure. If you want to enable mysql just for selected lists, put an ‘extend.py` in each list directory and leave the rest of your configuration as it is.

It is currently a good idea to avoid reserved words in your mailing list names. They’ll work in rails but not in python, where the quoting of some database queries seems to be less than perfect.

### Minor changes to the mailman table

The local table is already set up in a way that should work equally well with rails and mailman. If you’re using a remote mailman table, it will need a couple of small changes:

**An id column as primary key.** Strictly speaking we should define a composite primary key based on address & listname, but it’s much easier just to add an auto_incrementing id column and make that the primary key. Mailman doesn’t care as long as its columns are there. You probably also want to create a unique index on address+listname so that mailman gets the benefit and sees the expected behaviour.

**A membership_id column** We could (and used to) twist Activerecord out of shape by defining associations with address and listname primary keys between mailing list memberships and people and groups, but again it’s much easier just to belong_to a group membership. For that we need a membership_id column. Again, you will want an index on that column.

Defined Under Namespace

Modules: ClassMethods, DroomHelper, Folders, InstanceMethods, ModelHelpers, Taggability Classes: AgendaCategoriesController, AgendaCategory, Calendar, CalendarsController, Category, DashboardController, DashboardGenerator, DavResource, Document, DocumentAttachment, DocumentsController, DroomError, DropboxDocument, DropboxToken, DropboxTokensController, Engine, EngineController, Event, EventSet, EventsController, Folder, FoldersController, Group, GroupInvitation, GroupInvitationsController, GroupsController, InstallGenerator, Invitation, InvitationsController, LazyHash, MailingListMembership, Membership, MembershipsController, Organisation, OrganisationsController, Page, PagesController, PeopleController, PermissionDenied, Person, PersonalFolder, Preference, PreferencesController, PreferencesHash, RecurrenceRule, Scrap, ScrapsController, SuggestionsController, Tag, Tagging, User, UserActionObserver, UserConfirmationsController, UsersController, Venue, VenuesController, ViewsGenerator, YoutubeController

Constant Summary collapse

VERSION =
"0.4.2"

Class Method Summary collapse

Class Method Details

.add_suggestible_class(label, klass = nil) ⇒ Object



194
195
196
197
# File 'lib/droom.rb', line 194

def add_suggestible_class(label, klass=nil)
  klass ||= label.titlecase
  suggestible_classes[label] = klass.to_s
end

.aws_bucketObject



207
208
209
# File 'lib/droom.rb', line 207

def aws_bucket
  @@aws_bucket ||= Fog::Storage.new(Droom::Engine.config.paperclip_defaults[:fog_credentials]).directories.get(@@aws_bucket_name)
end

.aws_bucket_nameObject



203
204
205
# File 'lib/droom.rb', line 203

def aws_bucket_name
  @@aws_bucket_name ||= nil
end

.calendar_closed?Boolean

Returns:

  • (Boolean)


160
161
162
# File 'lib/droom.rb', line 160

def calendar_closed?
  !!@@calendar_closed
end

.dav_rootObject

base path of DAV directory tree, relative to rails root.



123
124
125
# File 'lib/droom.rb', line 123

def dav_root
  @@dav_root ||= "webdav"
end

.dav_subdomainObject

subdomain constraint applied when routing to dav.



128
129
130
# File 'lib/droom.rb', line 128

def dav_subdomain
  @@dav_subdomain ||= /dav/
end

.dropbox_app_nameObject



164
165
166
# File 'lib/droom.rb', line 164

def dropbox_app_name
  @@dropbox_app_name ||= 'droom'
end

.email_fromObject



78
79
80
# File 'lib/droom.rb', line 78

def email_from
  @@email_from ||= "[email protected]"
end

.email_from_nameObject



82
83
84
# File 'lib/droom.rb', line 82

def email_from_name
  @@email_from ||= "Please Set Email-From Name In Droom Initializer"
end

.email_hostObject



70
71
72
# File 'lib/droom.rb', line 70

def email_host
  @@email_host ||= "please-change-email-host-in-droom-initializer.example.com"
end

.email_layoutObject



74
75
76
# File 'lib/droom.rb', line 74

def email_layout
  @@email_layout ||= "droom/email"
end

.email_return_pathObject



86
87
88
# File 'lib/droom.rb', line 86

def email_return_path
  @@email_return_path ||= email_from
end

.enable_mailing_lists?Boolean

Returns:

  • (Boolean)


156
157
158
# File 'lib/droom.rb', line 156

def enable_mailing_lists?
  !!@@enable_mailing_lists
end

.home_countryObject



102
103
104
# File 'lib/droom.rb', line 102

def home_country
  Snail.home_country = @@home_country ||= 'gb'
end

.home_urlObject



62
63
64
# File 'lib/droom.rb', line 62

def home_url
  @@home_url ||= "http://example.com"
end

.layoutObject



66
67
68
# File 'lib/droom.rb', line 66

def layout
  @@layout ||= "droom/application"
end

.mailing_lists_active_by_default?Boolean

Returns:

  • (Boolean)


172
173
174
# File 'lib/droom.rb', line 172

def mailing_lists_active_by_default?
  !!@@mailing_lists_active_by_default
end

.mailing_lists_digest_by_default?Boolean

Returns:

  • (Boolean)


176
177
178
# File 'lib/droom.rb', line 176

def mailing_lists_digest_by_default?
  !!@@mailing_lists_digest_by_default
end

.mailman_table_nameObject



168
169
170
# File 'lib/droom.rb', line 168

def mailman_table_name
  @@mailman_table_name ||= 'mailman_mysql'
end

.main_dashboard_modulesObject



106
107
108
# File 'lib/droom.rb', line 106

def main_dashboard_modules
  @@main_dashboard_modules ||= %w{my_future_events my_folders}
end

.margin_dashboard_modulesObject



110
111
112
# File 'lib/droom.rb', line 110

def margin_dashboard_modules
  @@margin_dashboard_modules ||= %w{quicksearch stream}
end

.panelsObject



114
115
116
# File 'lib/droom.rb', line 114

def panels
  @@panels ||= %w{dropbox email rss devices readers account suggestions admin}
end

.people_sortObject



90
91
92
# File 'lib/droom.rb', line 90

def people_sort
  @@people_sort ||= "position ASC"
end

.required_calendar_namesObject



211
212
213
# File 'lib/droom.rb', line 211

def required_calendar_names
  @@required_calendar_names ||= %w{main stream}
end

.root_pathObject



98
99
100
# File 'lib/droom.rb', line 98

def root_path
  @@root_path ||= "dashboard#index"
end

.scrap_typesObject



118
119
120
# File 'lib/droom.rb', line 118

def scrap_types
  @@scrap_types ||= %w{image video text quote link event document}
end

.set_user_default(key, value) ⇒ Object

Here we are overriding droom default settings in a host app initializer to create local default settings. key should be dot-separated and string-like:

Droom.set_default('email.digest', true)

LazyHash#deep_set is a setter that can take compound keys and set nested values. It’s defined in lib/lazy_hash.rb.



246
247
248
# File 'lib/droom.rb', line 246

def set_user_default(key, value)
  user_defaults.set(key, value)
end

.show_venue_map?Boolean

Returns:

  • (Boolean)


180
181
182
# File 'lib/droom.rb', line 180

def show_venue_map?
  !!@@show_venue_map
end

.sign_out_pathObject



94
95
96
# File 'lib/droom.rb', line 94

def sign_out_path
  @@sign_out_path ||= "/users/sign_out"
end

.stream_shared?Boolean

Returns:

  • (Boolean)


148
149
150
# File 'lib/droom.rb', line 148

def stream_shared?
  !!@@stream_shared
end

.suggestible_classesObject



184
185
186
187
188
189
190
191
192
# File 'lib/droom.rb', line 184

def suggestible_classes
  @@suggestible_classes ||= {
    "event" => "Droom::Event", 
    "person" => "Droom::Person", 
    "document" => "Droom::Document",
    "group" => "Droom::Group",
    "venue" => "Droom::Venue"
  }
end

.use_biogs?Boolean

Returns:

  • (Boolean)


140
141
142
# File 'lib/droom.rb', line 140

def use_biogs?
  !!@@use_biogs
end

.use_forenames?Boolean

Returns:

  • (Boolean)


132
133
134
# File 'lib/droom.rb', line 132

def use_forenames?
  !!@@use_forenames
end

.use_organisations?Boolean

Returns:

  • (Boolean)


144
145
146
# File 'lib/droom.rb', line 144

def use_organisations?
  !!@@use_organisations
end

.use_separate_mobile_number?Boolean

Returns:

  • (Boolean)


152
153
154
# File 'lib/droom.rb', line 152

def use_separate_mobile_number?
  !!@@use_separate_mobile_number
end

.use_titles?Boolean

Returns:

  • (Boolean)


136
137
138
# File 'lib/droom.rb', line 136

def use_titles?
  !!@@use_titles
end

.user_default(key) ⇒ Object



250
251
252
# File 'lib/droom.rb', line 250

def user_default(key)
  user_defaults.get(key)
end

.user_defaultsObject

Droom’s preferences are arbitrary and open-ended. You can ask for any preference key: if it doesn’t exist you just get back the default value, or nil if there isn’t one. This is where you set the defaults.



219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
# File 'lib/droom.rb', line 219

def user_defaults
  @@user_defaults ||= Droom::LazyHash.new({
    :email =>  {
      :enabled? => true,
      :mailing_lists? => true,
      :event_invitations? => false,
      :digest? => false
    },
    :dropbox => {
      :strategy => "clicked",
      :events? => true,
    },
    :dav => {
      :enabled? => false,
      :strategy => "clicked",
      :everything? => false,
    }
  })
end

.yt_clientObject



199
200
201
# File 'lib/droom.rb', line 199

def yt_client
  @@yt_client ||= YouTubeIt::Client.new(:dev_key => "AI39si473p0K4e6id0ZrM1vniyk8pdbqr67hH39hyFjW_JQoLg9xi6BecWFtraoPMCeYQmRgIc_XudGKVU8tmeQF8VHwjOUg8Q")
end