{"action":"created","comment":{"url":"https://api.github.com/repos/duckduckgo/community-platform/pulls/comments/28230950","id":28230950,"diff_hunk":"@@ -0,0 +1,33 @@\n+package DDGC::Web::App::Base;\n+\n+use Import::Into;\n+\n+use strict;\n+use warnings;\n+use utf8;\n+\n+use Dancer2;\n+use Dancer2::Plugin::DBIC;\n+use DDGC::Web::Plugin::Config;\n+use DDGC::Web::Plugin::Session;\n+\n+{   no warnings 'redefine';\n+    sub import {\n+        my ($caller, $filename) = caller;\n+        for (\n+          qw/\n+            strict\n+            warnings\n+            utf8\n+            Dancer2\n+            Dancer2::Plugin::DBIC\n+            DDGC::Web::Plugin::Config\n+            DDGC::Web::Plugin::Session\n+          /\n+        ) {\n+            $_->import::into($caller);\n+        }\n+    }\n+};\n+\n+1;","path":"lib/DDGC/Web/App/Base.pm","position":33,"original_position":33,"commit_id":"b4a0b7fe3697db6898e6066308fc8e266e535a0a","original_commit_id":"b4a0b7fe3697db6898e6066308fc8e266e535a0a","user":{"login":"jbarrett","id":444449,"avatar_url":"https://avatars.githubusercontent.com/u/444449?v=3","gravatar_id":"","url":"https://api.github.com/users/jbarrett","html_url":"https://github.com/jbarrett","followers_url":"https://api.github.com/users/jbarrett/followers","following_url":"https://api.github.com/users/jbarrett/following{/other_user}","gists_url":"https://api.github.com/users/jbarrett/gists{/gist_id}","starred_url":"https://api.github.com/users/jbarrett/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jbarrett/subscriptions","organizations_url":"https://api.github.com/users/jbarrett/orgs","repos_url":"https://api.github.com/users/jbarrett/repos","events_url":"https://api.github.com/users/jbarrett/events{/privacy}","received_events_url":"https://api.github.com/users/jbarrett/received_events","type":"User","site_admin":false},"body":"Re `package DDGC::Web::App::Base`\r\n\r\n`Import::Into` performs an import step on any module of your choosing (so `'Foo'->import::into('Bar')` effectively inserts `use Foo` into `package Bar`).\r\n\r\nThis makes `DDGC::Web::App::Base` a \"base module\" (**not** a base class) which does the setup, exports and everything else `use`ing those modules would.\r\n\r\nThe reason for this is, each app or service has a number of required modules to do config and setup. While you can copypaste from a working application, this is prone to error. I wanted to make creating a new app much simpler. ([See this diff](https://github.com/duckduckgo/community-platform/commit/d9a547f))\r\n\r\n@MariagraziaAlastra @nilnilnil @jdorweiler @russellholt Any thoughts? Neat or horrific? I'm not sure.","created_at":"2015-04-13T11:34:09Z","updated_at":"2015-04-13T11:34:09Z","html_url":"https://github.com/duckduckgo/community-platform/pull/630#discussion_r28230950","pull_request_url":"https://api.github.com/repos/duckduckgo/community-platform/pulls/630","_links":{"self":{"href":"https://api.github.com/repos/duckduckgo/community-platform/pulls/comments/28230950"},"html":{"href":"https://github.com/duckduckgo/community-platform/pull/630#discussion_r28230950"},"pull_request":{"href":"https://api.github.com/repos/duckduckgo/community-platform/pulls/630"}}},"pull_request":{"url":"https://api.github.com/repos/duckduckgo/community-platform/pulls/630","id":32893100,"html_url":"https://github.com/duckduckgo/community-platform/pull/630","diff_url":"https://github.com/duckduckgo/community-platform/pull/630.diff","patch_url":"https://github.com/duckduckgo/community-platform/pull/630.patch","issue_url":"https://api.github.com/repos/duckduckgo/community-platform/issues/630","number":630,"state":"open","locked":false,"title":"For Comment: Blog \"Service\"","user":{"login":"jbarrett","id":444449,"avatar_url":"https://avatars.githubusercontent.com/u/444449?v=3","gravatar_id":"","url":"https://api.github.com/users/jbarrett","html_url":"https://github.com/jbarrett","followers_url":"https://api.github.com/users/jbarrett/followers","following_url":"https://api.github.com/users/jbarrett/following{/other_user}","gists_url":"https://api.github.com/users/jbarrett/gists{/gist_id}","starred_url":"https://api.github.com/users/jbarrett/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jbarrett/subscriptions","organizations_url":"https://api.github.com/users/jbarrett/orgs","repos_url":"https://api.github.com/users/jbarrett/repos","events_url":"https://api.github.com/users/jbarrett/events{/privacy}","received_events_url":"https://api.github.com/users/jbarrett/received_events","type":"User","site_admin":false},"body":"@MariagraziaAlastra @nilnilnil @zekiel @jdorweiler @russellholt \r\n\r\nThis is currently Not Working, but I'll go a little into what's different here from the last PR and what's needed to get moving.\r\n\r\nBiggest change from the last discussed PR is using the plugin architecture to wrap DDGC::Config and PSGI Sessions (so e.g. just `use DDGC::Web::Plugin::Session` should populate a user variable in the request, if there is a current user)\r\n\r\nRe-using the model and templates is possibly too messy - attempting a more significant change here has exposed some stuff which won't work or is impractical, e.g.\r\n\r\n- Instances of `DDGC` are heavily relied on by **most or all** components (usually passed in on instantiation)\r\n- `DDGC::DB` does not use a standard schema constructor / connect call so can't just be used as a DBIx::Class schema (with Plugin::DBIC say)\r\n- Templates rely heavily on functionality in [`DDGC`'s Xslate constructor](https://github.com/duckduckgo/community-platform/blob/72a6e3930ca59fee4d087aa966a0c715b79c329f/lib/DDGC.pm#L233-L450) or [`DDGC::Web::View::Xslate`](https://github.com/duckduckgo/community-platform/blob/72a6e3930ca59fee4d087aa966a0c715b79c329f/lib/DDGC/Web/View/Xslate.pm)\r\n\r\nSo for this to work without depending too much on the extant architecture (i.e. to be as discrete as possible from the start), there needs to be parallel development on a DB Schema and views which implement parts that makes sense and leaves behind parts that don't.\r\n\r\nThere are modules like [`DDGC::Markup`](https://github.com/duckduckgo/community-platform/blob/72a6e3930ca59fee4d087aa966a0c715b79c329f/lib/DDGC/Markup.pm) which are instantiated as a member of, and passed a reference to, a `DDGC` instance. These types of instances should probably be plain modules with exports. Where a dependency on session or request parameters exists, they can be passed as parameters, though efforts should be made to reduce this type of dependency anyway.\r\n\r\nNo insurmountable challenges yet :)\r\n\r\nMore tomorrow...","created_at":"2015-04-08T19:25:40Z","updated_at":"2015-04-13T11:34:09Z","closed_at":null,"merged_at":null,"merge_commit_sha":"035260b0607f7dc6091395d95d835ae01742aa5d","assignee":{"login":"jbarrett","id":444449,"avatar_url":"https://avatars.githubusercontent.com/u/444449?v=3","gravatar_id":"","url":"https://api.github.com/users/jbarrett","html_url":"https://github.com/jbarrett","followers_url":"https://api.github.com/users/jbarrett/followers","following_url":"https://api.github.com/users/jbarrett/following{/other_user}","gists_url":"https://api.github.com/users/jbarrett/gists{/gist_id}","starred_url":"https://api.github.com/users/jbarrett/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jbarrett/subscriptions","organizations_url":"https://api.github.com/users/jbarrett/orgs","repos_url":"https://api.github.com/users/jbarrett/repos","events_url":"https://api.github.com/users/jbarrett/events{/privacy}","received_events_url":"https://api.github.com/users/jbarrett/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/duckduckgo/community-platform/pulls/630/commits","review_comments_url":"https://api.github.com/repos/duckduckgo/community-platform/pulls/630/comments","review_comment_url":"https://api.github.com/repos/duckduckgo/community-platform/pulls/comments{/number}","comments_url":"https://api.github.com/repos/duckduckgo/community-platform/issues/630/comments","statuses_url":"https://api.github.com/repos/duckduckgo/community-platform/statuses/b4a0b7fe3697db6898e6066308fc8e266e535a0a","head":{"label":"duckduckgo:john/blog-service","ref":"john/blog-service","sha":"b4a0b7fe3697db6898e6066308fc8e266e535a0a","user":{"login":"duckduckgo","id":342708,"avatar_url":"https://avatars.githubusercontent.com/u/342708?v=3","gravatar_id":"","url":"https://api.github.com/users/duckduckgo","html_url":"https://github.com/duckduckgo","followers_url":"https://api.github.com/users/duckduckgo/followers","following_url":"https://api.github.com/users/duckduckgo/following{/other_user}","gists_url":"https://api.github.com/users/duckduckgo/gists{/gist_id}","starred_url":"https://api.github.com/users/duckduckgo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/duckduckgo/subscriptions","organizations_url":"https://api.github.com/users/duckduckgo/orgs","repos_url":"https://api.github.com/users/duckduckgo/repos","events_url":"https://api.github.com/users/duckduckgo/events{/privacy}","received_events_url":"https://api.github.com/users/duckduckgo/received_events","type":"Organization","site_admin":false},"repo":{"id":1751775,"name":"community-platform","full_name":"duckduckgo/community-platform","owner":{"login":"duckduckgo","id":342708,"avatar_url":"https://avatars.githubusercontent.com/u/342708?v=3","gravatar_id":"","url":"https://api.github.com/users/duckduckgo","html_url":"https://github.com/duckduckgo","followers_url":"https://api.github.com/users/duckduckgo/followers","following_url":"https://api.github.com/users/duckduckgo/following{/other_user}","gists_url":"https://api.github.com/users/duckduckgo/gists{/gist_id}","starred_url":"https://api.github.com/users/duckduckgo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/duckduckgo/subscriptions","organizations_url":"https://api.github.com/users/duckduckgo/orgs","repos_url":"https://api.github.com/users/duckduckgo/repos","events_url":"https://api.github.com/users/duckduckgo/events{/privacy}","received_events_url":"https://api.github.com/users/duckduckgo/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/duckduckgo/community-platform","description":"DuckDuckGo Community Platform","fork":false,"url":"https://api.github.com/repos/duckduckgo/community-platform","forks_url":"https://api.github.com/repos/duckduckgo/community-platform/forks","keys_url":"https://api.github.com/repos/duckduckgo/community-platform/keys{/key_id}","collaborators_url":"https://api.github.com/repos/duckduckgo/community-platform/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/duckduckgo/community-platform/teams","hooks_url":"https://api.github.com/repos/duckduckgo/community-platform/hooks","issue_events_url":"https://api.github.com/repos/duckduckgo/community-platform/issues/events{/number}","events_url":"https://api.github.com/repos/duckduckgo/community-platform/events","assignees_url":"https://api.github.com/repos/duckduckgo/community-platform/assignees{/user}","branches_url":"https://api.github.com/repos/duckduckgo/community-platform/branches{/branch}","tags_url":"https://api.github.com/repos/duckduckgo/community-platform/tags","blobs_url":"https://api.github.com/repos/duckduckgo/community-platform/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/duckduckgo/community-platform/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/duckduckgo/community-platform/git/refs{/sha}","trees_url":"https://api.github.com/repos/duckduckgo/community-platform/git/trees{/sha}","statuses_url":"https://api.github.com/repos/duckduckgo/community-platform/statuses/{sha}","languages_url":"https://api.github.com/repos/duckduckgo/community-platform/languages","stargazers_url":"https://api.github.com/repos/duckduckgo/community-platform/stargazers","contributors_url":"https://api.github.com/repos/duckduckgo/community-platform/contributors","subscribers_url":"https://api.github.com/repos/duckduckgo/community-platform/subscribers","subscription_url":"https://api.github.com/repos/duckduckgo/community-platform/subscription","commits_url":"https://api.github.com/repos/duckduckgo/community-platform/commits{/sha}","git_commits_url":"https://api.github.com/repos/duckduckgo/community-platform/git/commits{/sha}","comments_url":"https://api.github.com/repos/duckduckgo/community-platform/comments{/number}","issue_comment_url":"https://api.github.com/repos/duckduckgo/community-platform/issues/comments{/number}","contents_url":"https://api.github.com/repos/duckduckgo/community-platform/contents/{+path}","compare_url":"https://api.github.com/repos/duckduckgo/community-platform/compare/{base}...{head}","merges_url":"https://api.github.com/repos/duckduckgo/community-platform/merges","archive_url":"https://api.github.com/repos/duckduckgo/community-platform/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/duckduckgo/community-platform/downloads","issues_url":"https://api.github.com/repos/duckduckgo/community-platform/issues{/number}","pulls_url":"https://api.github.com/repos/duckduckgo/community-platform/pulls{/number}","milestones_url":"https://api.github.com/repos/duckduckgo/community-platform/milestones{/number}","notifications_url":"https://api.github.com/repos/duckduckgo/community-platform/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/duckduckgo/community-platform/labels{/name}","releases_url":"https://api.github.com/repos/duckduckgo/community-platform/releases{/id}","created_at":"2011-05-15T17:35:41Z","updated_at":"2015-04-12T20:38:13Z","pushed_at":"2015-04-13T11:24:01Z","git_url":"git://github.com/duckduckgo/community-platform.git","ssh_url":"git@github.com:duckduckgo/community-platform.git","clone_url":"https://github.com/duckduckgo/community-platform.git","svn_url":"https://github.com/duckduckgo/community-platform","homepage":"https://duck.co/","size":36619,"stargazers_count":324,"watchers_count":324,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":83,"mirror_url":null,"open_issues_count":104,"forks":83,"open_issues":104,"watchers":324,"default_branch":"dev"}},"base":{"label":"duckduckgo:dev","ref":"dev","sha":"72a6e3930ca59fee4d087aa966a0c715b79c329f","user":{"login":"duckduckgo","id":342708,"avatar_url":"https://avatars.githubusercontent.com/u/342708?v=3","gravatar_id":"","url":"https://api.github.com/users/duckduckgo","html_url":"https://github.com/duckduckgo","followers_url":"https://api.github.com/users/duckduckgo/followers","following_url":"https://api.github.com/users/duckduckgo/following{/other_user}","gists_url":"https://api.github.com/users/duckduckgo/gists{/gist_id}","starred_url":"https://api.github.com/users/duckduckgo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/duckduckgo/subscriptions","organizations_url":"https://api.github.com/users/duckduckgo/orgs","repos_url":"https://api.github.com/users/duckduckgo/repos","events_url":"https://api.github.com/users/duckduckgo/events{/privacy}","received_events_url":"https://api.github.com/users/duckduckgo/received_events","type":"Organization","site_admin":false},"repo":{"id":1751775,"name":"community-platform","full_name":"duckduckgo/community-platform","owner":{"login":"duckduckgo","id":342708,"avatar_url":"https://avatars.githubusercontent.com/u/342708?v=3","gravatar_id":"","url":"https://api.github.com/users/duckduckgo","html_url":"https://github.com/duckduckgo","followers_url":"https://api.github.com/users/duckduckgo/followers","following_url":"https://api.github.com/users/duckduckgo/following{/other_user}","gists_url":"https://api.github.com/users/duckduckgo/gists{/gist_id}","starred_url":"https://api.github.com/users/duckduckgo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/duckduckgo/subscriptions","organizations_url":"https://api.github.com/users/duckduckgo/orgs","repos_url":"https://api.github.com/users/duckduckgo/repos","events_url":"https://api.github.com/users/duckduckgo/events{/privacy}","received_events_url":"https://api.github.com/users/duckduckgo/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/duckduckgo/community-platform","description":"DuckDuckGo Community Platform","fork":false,"url":"https://api.github.com/repos/duckduckgo/community-platform","forks_url":"https://api.github.com/repos/duckduckgo/community-platform/forks","keys_url":"https://api.github.com/repos/duckduckgo/community-platform/keys{/key_id}","collaborators_url":"https://api.github.com/repos/duckduckgo/community-platform/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/duckduckgo/community-platform/teams","hooks_url":"https://api.github.com/repos/duckduckgo/community-platform/hooks","issue_events_url":"https://api.github.com/repos/duckduckgo/community-platform/issues/events{/number}","events_url":"https://api.github.com/repos/duckduckgo/community-platform/events","assignees_url":"https://api.github.com/repos/duckduckgo/community-platform/assignees{/user}","branches_url":"https://api.github.com/repos/duckduckgo/community-platform/branches{/branch}","tags_url":"https://api.github.com/repos/duckduckgo/community-platform/tags","blobs_url":"https://api.github.com/repos/duckduckgo/community-platform/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/duckduckgo/community-platform/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/duckduckgo/community-platform/git/refs{/sha}","trees_url":"https://api.github.com/repos/duckduckgo/community-platform/git/trees{/sha}","statuses_url":"https://api.github.com/repos/duckduckgo/community-platform/statuses/{sha}","languages_url":"https://api.github.com/repos/duckduckgo/community-platform/languages","stargazers_url":"https://api.github.com/repos/duckduckgo/community-platform/stargazers","contributors_url":"https://api.github.com/repos/duckduckgo/community-platform/contributors","subscribers_url":"https://api.github.com/repos/duckduckgo/community-platform/subscribers","subscription_url":"https://api.github.com/repos/duckduckgo/community-platform/subscription","commits_url":"https://api.github.com/repos/duckduckgo/community-platform/commits{/sha}","git_commits_url":"https://api.github.com/repos/duckduckgo/community-platform/git/commits{/sha}","comments_url":"https://api.github.com/repos/duckduckgo/community-platform/comments{/number}","issue_comment_url":"https://api.github.com/repos/duckduckgo/community-platform/issues/comments{/number}","contents_url":"https://api.github.com/repos/duckduckgo/community-platform/contents/{+path}","compare_url":"https://api.github.com/repos/duckduckgo/community-platform/compare/{base}...{head}","merges_url":"https://api.github.com/repos/duckduckgo/community-platform/merges","archive_url":"https://api.github.com/repos/duckduckgo/community-platform/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/duckduckgo/community-platform/downloads","issues_url":"https://api.github.com/repos/duckduckgo/community-platform/issues{/number}","pulls_url":"https://api.github.com/repos/duckduckgo/community-platform/pulls{/number}","milestones_url":"https://api.github.com/repos/duckduckgo/community-platform/milestones{/number}","notifications_url":"https://api.github.com/repos/duckduckgo/community-platform/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/duckduckgo/community-platform/labels{/name}","releases_url":"https://api.github.com/repos/duckduckgo/community-platform/releases{/id}","created_at":"2011-05-15T17:35:41Z","updated_at":"2015-04-12T20:38:13Z","pushed_at":"2015-04-13T11:24:01Z","git_url":"git://github.com/duckduckgo/community-platform.git","ssh_url":"git@github.com:duckduckgo/community-platform.git","clone_url":"https://github.com/duckduckgo/community-platform.git","svn_url":"https://github.com/duckduckgo/community-platform","homepage":"https://duck.co/","size":36619,"stargazers_count":324,"watchers_count":324,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":83,"mirror_url":null,"open_issues_count":104,"forks":83,"open_issues":104,"watchers":324,"default_branch":"dev"}},"_links":{"self":{"href":"https://api.github.com/repos/duckduckgo/community-platform/pulls/630"},"html":{"href":"https://github.com/duckduckgo/community-platform/pull/630"},"issue":{"href":"https://api.github.com/repos/duckduckgo/community-platform/issues/630"},"comments":{"href":"https://api.github.com/repos/duckduckgo/community-platform/issues/630/comments"},"review_comments":{"href":"https://api.github.com/repos/duckduckgo/community-platform/pulls/630/comments"},"review_comment":{"href":"https://api.github.com/repos/duckduckgo/community-platform/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/duckduckgo/community-platform/pulls/630/commits"},"statuses":{"href":"https://api.github.com/repos/duckduckgo/community-platform/statuses/b4a0b7fe3697db6898e6066308fc8e266e535a0a"}}}}