示例#1
0
exports.updateMessage = function (message) {
    CONFIG.cli.update.render(Utils.overlap(bOut, message, bOut.split("\n").length - 2, "center").trim(), false);
};
示例#2
0
    Stream(function (err, data) {
        if (err) { return callback(err); }
        Config.currentFrame = "news-feed";

        var timeline = new Table();
        timeline.addRow(["#", {
            text: "Type"
          , data: {
                width: 8
              , hAlign: "center"
            }
        }, "Description", {
            text: "Time"
          , data: {
                width: 18
            }
        }]);

        var offsetTop = 10
          , show =  Math.floor((Config.cli.h - offsetTop - 3) / 2) - 1
          ;

        if (show > data.length) {
            show = data.length;
        }

        for (var i = 0; i < show; ++i) {
            var cEv = data[i];

            timeline.addRow([{
                text: i + 1
              , data: {
                    vAlign: "middle"
                  , width: 6
                }
            }, {
                text: cEv.icon
              , data: {
                    hAlign: "center"
                  , vAlign: "middle"
                }
            }, {
                text: cEv.description
              , data: {
                    vAlign: "middle"
                }
            }, {
                text: cEv.time
              , data: {
                    vAlign: "middle"
                  , width: 18
                }
            }]);
        }

        var cTimeline = timeline.stringify()
          , output = Overlap({
                who: Config.background.toString()
              , with: cTimeline
              , where: {
                    x: Config.cli.w / 2 - cTimeline.split("\n")[0].length / 2
                  , y: 10
                }
            })
          ;

        output = Utils.overlap(output, [
            Config.title
          , " - - - "
          , Config.description
          , ""
          , "-----------------------------------------------------------------"
          , "(C)reate new repository | (P)rofile | (I)ssues | Pull (R)equests"
          , "-----------------------------------------------------------------"
        ], 2, "center");
        Config.cli.update.render(output.trim(), true, {
            currentFrame: Config.currentFrame
        });
    });
示例#3
0
    UserList(options, function (err, data) {
        if (err) { return callback(err); }
        Config.currentFrame = "user-list";

        var offsetTop = 10
          , show =  Math.floor((Config.cli.h - offsetTop - 3) / 2) - 1
          , yLimit = show
          , xLimit = Math.floor(Config.cli.w / 32)
          ;

        if (yLimit > data.length) {
            yLimit = data.length;
        }

        var tables = [];
        outer_loop:
        for (var x = 0; x < xLimit; ++x) {
            if (!data[x * yLimit]) {
                break;
            }
            var users = new Table();
            tables.push(users);
            users.addRow(["#", {
                text: "Login"
              , data: {
                    width: 23
                  , hAlign: "center"
                }
            }]);
            for (var y = 0; y < yLimit; ++y) {
                var cUser = data[x * yLimit + y];
                if (!cUser) {
                    break outer_loop;
                }
                users.addRow([{
                    text: x * yLimit + y + 1
                  , data: {
                        width: 6
                    }
                }, {
                    text: "@" + cUser.login
                  , data: {
                        width: 23
                    }
                }]);
            }
        }

        var allTables = null;
        if (!tables[0]) {
            allTables = "No users fetched.";
        } else {
            allTables = tables[0].toString();
            for (var i = 1; i < tables.length; ++i) {
                allTables = Overlap({
                    who: allTables
                  , with: tables[i].toString()
                  , where: {
                        x: i * 29
                      , y: 0
                    }
                });
            }
        }

        var output = Overlap({
                who: Config.background.toString()
              , with: allTables
              , where: {
                    x: Config.cli.w / 2 - allTables.split("\n")[0].length / 2
                  , y: 10
                }
            })
          , desc = {
                followers: "@" + options.user + "'s followers"
              , following: "@" + options.user + "'s following"
              , members: "@" + options.user + "'s members"
            }
          ;

        output = Utils.overlap(output, [
            Config.title
          , " - - - "
          , Config.description
          , ""
          , "-----------------------------------------------------------------"
          , desc[options.type]
          , "-----------------------------------------------------------------"
        ], 2, "center");
        Config.cli.update.render(output.trim(), true, {
            currentFrame: Config.currentFrame
        });
    });
示例#4
0
        getAvatar(data, function (err, cAvatar) {
            if (err) {
                return callback(err);
            }

            // Profile
            var profileScreen = Overlap({
                who: Config.background.toString()
              , with: cAvatar
              , where: {
                    x: 3
                  , y: 2
                }
            });
            var info = []
              , name = data.name + " (@" + data.login + ")"
              , separator = Array(name.length).join("-")
              ;

            info.push(separator);
            info.push(name)
            info.push(separator);
            if (data.company) { info.push("♟  " + data.company); }
            if (data.location) { info.push("༐ " + data.location); }
            if (data.email) { info.push("✉ " + data.email); }
            if (data.blog) { info.push("⊜  " + data.blog); }
            if (data.created_at) { info.push("⇴ Joined on " + Moment(data.created_at).format("LL")); }
            info.push(separator);
            if (data.type === "User") {
                info.push("Followe(R)s: " + data.followers);
                info.push("Followi(N)g: " + data.following);
            } else if (data.type === "Organization") {
                info.push("Press SHIFT + M to see the organization members.");
            }

            profileScreen = Utils.overlap(profileScreen, info, cAvatar.split("\n").length + 2, 3);

            // Repositories
            var repos = new Table();
            repos.addRow(["#", "Type", "Name", "SSH URL"]);
            var show = Math.floor((Config.cli.h - 3) / 2) - 3;
            if (show > data.repos.length) {
                show = data.repos.length;
            }

            for (var i = 0; i < show; ++i) {
                var cRepo = data.repos[i]
                  , type = "source"
                  ;

                if (cRepo.fork) { type = "fork"; }
                if (cRepo.private) { type = "private"; }

                repos.addRow([i + 1, type, cRepo.name, cRepo.ssh_url]);
            }

            var cRepos = repos.stringify().trim();
            profileScreen = Utils.overlap(profileScreen, [
                "Repositories"
              , cRepos
            ], 2, cAvatar.split("\n")[0].length + 5);

            // Organizations
            var orgs = new Table();
            orgs.addRow(["#", "Name"]);

            for (var i = 0; i < data.orgs.length; ++i) {
                var cOrg = data.orgs[i];
                orgs.addRow([i + 1, cOrg.login]);
            }

            if (data.orgs.length) {
                profileScreen = Utils.overlap(profileScreen, [
                    "Organizations"
                  , orgs.stringify().trim()
                ], 2, cAvatar.split("\n")[0].length + 5 + cRepos.split("\n")[0].length + 3);
            }

            Config.currentFrame = "profile";
            Config.cFrameData = data;

            Config.cli.update.render(profileScreen.trim(), true, {
                currentFrame: Config.currentFrame
            });
        });