{"size": 2500, "ext": "js", "max_stars_repo_path": "modules/blog/admin.js", "max_stars_repo_name": "san4osq/tarann", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "modules/blog/admin.js", "max_issues_repo_name": "san4osq/tarann", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "modules/blog/admin.js", "max_forks_repo_name": "san4osq/tarann", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 2500.0, "max_line_length": 2500, "alphanum_fraction": 0.704}
module.exports=function(e){var o=e.get("express").Router(),t=require("path"),n=(require("mongodb").ObjectID,new(require("i18n-2"))({locales:e.get("config").locales.avail,directory:t.join(__dirname,"lang"),extension:".js",devMode:e.get("config").locales.dev_mode}));return o.get_module_name=function(e){return n.setLocale(e.session.current_locale),n.__("module_name_cp")},o.get("/",function(o,s){return n.setLocale(o.session.current_locale),!o.session.auth||o.session.auth.status<2?(o.session.auth_redirect_host=o.get("host"),o.session.auth_redirect="/cp/blog",void s.redirect(303,"/auth/cp?rnd="+Math.random().toString().replace(".",""))):void e.get("mongodb").collection("settings").find({$or:[{oname:"blog_mode"},{oname:"blog_areas"}]}).toArray(function(i,r){var a="",l="[]";if(r&&2==r.length)for(var g=0;g<r.length;g++)"blog_mode"==r[g].oname&&(a=r[g].ovalue),"blog_areas"==r[g].oname&&(l=r[g].ovalue);var u=e.get("renderer").render_file(t.join(__dirname,"views"),"blog_cp",{lang:n,auth:o.session.auth,init_mode:a,init_areas:l,locales:JSON.stringify(e.get("config").locales.avail)},o);e.get("cp").render(o,s,{body:u,css:'<link rel="stylesheet" href="/modules/blog/css/main.css">'},n,"blog_cp",o.session.auth)})}),o.post("/config/save",function(o,t){n.setLocale(o.session.current_locale);var s={status:1};if(!o.session.auth||o.session.auth.status<2)return s.status=0,s.error=n.__("unauth"),void t.send(JSON.stringify(s));var i=o.body.mode,r=o.body.areas;return"private"!=i&&"moderation"!=i&&"public"!=i?(s.status=0,t.send(JSON.stringify(s))):(r&&(r=JSON.stringify(r)),r?(e.get("mongodb").collection("settings").find({$or:[{oname:"blog_mode"},{oname:"blog_areas"}]}).toArray(function(o,n){return o?(s.status=0,t.send(JSON.stringify(s))):void(n&&n.length?e.get("mongodb").collection("settings").update({oname:"blog_mode"},{$set:{ovalue:i,olang:""}},function(o){return o?(s.status=0,t.send(JSON.stringify(s))):void e.get("mongodb").collection("settings").update({oname:"blog_areas"},{$set:{ovalue:r,olang:""}},function(e){return e?(s.status=0,t.send(JSON.stringify(s))):t.send(JSON.stringify(s))})}):e.get("mongodb").collection("settings").insert({oname:"blog_mode",ovalue:i,olang:""},function(o){return o?(s.status=0,t.send(JSON.stringify(s))):void e.get("mongodb").collection("settings").insert({oname:"blog_areas",ovalue:r,olang:""},function(e){return e?(s.status=0,t.send(JSON.stringify(s))):t.send(JSON.stringify(s))})}))}),t.send(JSON.stringify(s))):(s.status=0,t.send(JSON.stringify(s))))}),o};