geekhub

package module
v0.0.0-...-b5edb28 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 21, 2020 License: MIT Imports: 16 Imported by: 0

README

Geekhub.com 终端版

安装
下载二进制运行

进入 release 下载对应系统的版本

手动安装
git clone https://github.com/rrylee/geekterm.git

cd geekterm/cli

go run --mod=vendor . --cookie="你的浏览器cookie"

获取登录 cookie 请移动到 wiki

常用操作
  1. enter 或者 -> 进入帖子列表
  2. j,k 上下,然后 enter 进入内容,继续 j 滑动到评论列表
查看个人动态->回帖
  1. i 进入个人动态
  2. k 向下移动,j 向上移动,选择要查看的帖子
  3. enter 进入帖子
  4. k 向下移动,j 向上移动,选择评论列表
  5. r 回帖,并且会回复当前楼层
  6. R 直接回帖
  7. 如果不想回帖了,ESC 返回
详细键位

如果你之前习惯使用 vim,那么这套操作你会非常舒服,基本上可以单手操作

键位 功能 说明
h <- 可以在各个面板中跳转
j down
k up
l <-
<- <- 增加了跳转
-> -> 增加了跳转
i 查看个人动态
o 打开浏览器 选中帖子,打开帖子,在动态,打开动态
M 进入留言列表
r 回帖 如果有选中的留言,直接回复留言
R 直接回帖
m 上一页 帖子列表和留言
n 下一页 帖子列表和留言
q 退出
enter 回复评论 在评论列表和个人中心
enter 加载 加载选择帖子内容
TODO
  • 基础功能
  • vim 键位
  • 从浏览器打开文章页面
  • 回贴
  • 评论分页加载
  • 自动签到
  • 分子详情展示
  • 未识别动态, 按enter 打开 github issue 页面
  • 自动登录
  • 帖子图片
  • 配色自定义
  • 自定义键位
  • 自定义签名

Documentation

Index

Constants

View Source
const (
	HomePage       = "https://geekhub.com/"
	PostsURI       = "posts"
	SecondHandsURI = "second_hands"
	AuctionsURI    = "auctions"
	MoleculesURI   = "molecules"
	GroupBuysURI   = "group_buys"
	ActivitiesURI  = "activities"
	PostCommentURI = "comments"
	GbitOrderURI   = "gbit_orders"
	CheckinsURI    = "checkins"
	SignURI        = "checkins/start"
)
View Source
const (
	ReplyPost = iota
	GbitOrder
	GetMolecules        //抢到分子
	YourMoleculesFinish //分子结束
	OrderComment        //评价订单
	Unknow              //未识别的
)
View Source
const (
	PostType       postType = "Post"
	SecondHandType          = "SecondHand"
	AuctionType             = "Auction"
	MoleculeType            = "Molecule"
	GroupBuyType            = "GroupBuy"
)
View Source
const DefaultAuthRefreshIntervel = 60 * time.Second
View Source
const DefaultSign = "\n\n 「来自 geekterm」"
View Source
const DefaultUserAgent = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/52.0.2743.82 Safari/537.36"
View Source
const VersionFile = "https://raw.githubusercontent.com/rrylee/geekterm/master/version.txt"

Variables

View Source
var (
	InternetError = errors.New("Internet Error.")
	GoQueryError  = errors.New("GoQuery error.")
)
View Source
var Converter *converter
View Source
var ShutcutKeys = [][3]string{
	{"上下左右", "正常移动", "左右可以切换不同的窗口"},
	{"j k h l", "对应以上", ""},
	{"i", "查看个人动态", ""},
	{"o", "打开到浏览器", "选中帖子,打开帖子,在动态,打开动态"},
	{"n", "上一页", "帖子列表,评论列表"},
	{"m", "下一页", "帖子列表,评论列表"},
	{"r", "回帖", "如果选中某条评论,会回复留言"},
	{"R", "回帖", "直接回帖"},
	{"M", "直接进入评论列表", ""},
	{"q", "退出程序", ""},
	{"enter", "各种确定操作", "加载帖子,提交评论"},
	{"esc", "退出", "个人动态页使用"},
	{"tab", "切换", "在评论弹窗切换选中区"},
}
View Source
var ShutcutTitles = []string{"键位", "功能", "备注"}
View Source
var Version = "beta0.4"
View Source
var VersionPublishOrder = []string{
	"beta0.1",
	"beta0.2",
	"beta0.3",
	"beta0.4",
}

Functions

func Debugf

func Debugf(format string, args ...interface{})

func Draw

func Draw()

func Infof

func Infof(format string, args ...interface{})

func Keybinds

func Keybinds()

func OpenChrome

func OpenChrome(openable Openable) error

func Run

func Run() error

func Setup

func Setup(cfg *Config)

func Warnf

func Warnf(format string, args ...interface{})

func WatchUpgrade

func WatchUpgrade()

Types

type ActivitiesPageResponse

type ActivitiesPageResponse struct {
	*BasePageInfo
	Activities []*Activity
}

type Activity

type Activity struct {
	Type        ActivityType
	TargetUri   string
	TargetTitle string
	Content     string
	User        *User
	Time        string
}

func (*Activity) GetUrl

func (a *Activity) GetUrl() string

type ActivityType

type ActivityType int8

type AuthInfo

type AuthInfo struct {
	NotifyCount string //动态条数
	Me          *User  //用户信息
}

type AuthStatus

type AuthStatus int8
const (
	NotLogin AuthStatus = 0
	Logan    AuthStatus = 1
)

type BasePageInfo

type BasePageInfo struct {
	AuthInfo *AuthInfo
	Status   AuthStatus
}

type Category

type Category struct {
	// contains filtered or unexported fields
}

type Comment

type Comment struct {
	ID          string
	Author      *User
	CommentTime string
	Content     string
	Floor       string
	Parent      *Comment
}

type Config

type Config struct {
	Cookie    string //登录cookie
	ReplySign string //回复签名
	LogFile   string
	LogLevel  int
}
var MyConfig *Config

type ConfigAttrSelectors

type ConfigAttrSelectors struct {
	PostList                  string
	Post                      string
	PostHref                  string
	TextUser                  string //用户名(纯文字的)
	PostCommentCount          string
	AuthStatus                string //右上角登录状态
	PostBody                  string
	PostPageCommentCount      string //post页面的评论数量标签
	CommentList               string
	CommentContent            string
	PostPageAuthor            string
	PostPageTitle             string
	ActivityCount             string
	AuthUsername              string
	CommentAuthor             string
	CommentTime               string
	CommentFloor              string
	Activities                string
	ActivityTargetUri         string
	ActivityTargetTitle       string
	ActivityReplyContent      string
	ActivityBody              string //整个动态中间内容区域
	ActivityUser              string
	ActivityTime              string
	ActivityGetMoleculesLink  string
	ActivityYourMoleculesLink string
	ReplyToken                string
	CommentParentUser         string
	CommentParentContent      string
	CommentCurPage            string
	CheckInButton             string
	MoleculeSeconds           string
}

func GetDefaultConfigAttrSelectors

func GetDefaultConfigAttrSelectors() *ConfigAttrSelectors

type ContentPageResponse

type ContentPageResponse struct {
	*BasePageInfo
	Post *DetailPost
}

type Convert

type Convert interface {
	Html2Md(*goquery.Selection) string
}

type DetailPost

type DetailPost struct {
	ID               string
	Title            string
	Content          string
	PostType         postType
	Uri              string
	Author           *User
	PublishTime      string
	PV               string
	CommentCount     int64
	CommentTotalPage int64
	CurCommentPage   int
	Comments         []*Comment
	ExtraInfo        interface{}
	// contains filtered or unexported fields
}

func (DetailPost) GetUrl

func (p DetailPost) GetUrl() string

type IGeekHub

type IGeekHub interface {
	GetMePage(userUri string) (*MePageResponse, error) //个人中心
	GetHomePage(page int) (*PostPageResponse, error)
	GetPostsPage(page int) (*PostPageResponse, error)
	GetSecondHandsPage(page int) (*PostPageResponse, error)
	GetAuctionsPage(page int) (*PostPageResponse, error)
	GetMoleculesPage(page int) (*PostPageResponse, error)
	GetGroupBuysPage(page int) (*PostPageResponse, error)

	GetPostContent(pageUri string, page int) (*ContentPageResponse, error)
	GetActivities(page int) (*ActivitiesPageResponse, error)
	PostComment(arg *PostCommentArgs) error

	GetSignStatus() (bool, string, error) //获取签到状态
	CheckIn(token string) error           //签到
}
var (
	GeekHub IGeekHub
)

type MePageResponse

type MePageResponse struct {
	*BasePageInfo
}

type MoleculesInfo

type MoleculesInfo struct {
	Name        string
	Price       string
	Molecule    string //分子
	Denominator string //分母
	HowToSend   string
	Contact     string
	CountDown   int //倒计时
	Floor       string
}

type NewVersion

type NewVersion struct {
	// contains filtered or unexported fields
}

func CheckNewVersion

func CheckNewVersion() (hasNewVersion bool, newVersion *NewVersion, err error)

type Openable

type Openable interface {
	GetUrl() string
}

func NewOpenableUrl

func NewOpenableUrl(url string) Openable

type PostCommentArgs

type PostCommentArgs struct {
	AuthenticityToken string
	TargetType        postType
	TargetId          string
	ReplyToId         string
	Content           string
}

type PostPageResponse

type PostPageResponse struct {
	*BasePageInfo
	Posts []*PreviewPost
}

type PreviewPost

type PreviewPost struct {
	ID              string
	Title           string
	Uri             string
	Author          *User
	CommentCount    int64
	LatestReplyTime string
	LatestReplyUser *User
}

func (PreviewPost) GetUrl

func (p PreviewPost) GetUrl() string

type User

type User struct {
	Username   string
	PageUri    string
	UserDetail *UserDetail
}

type UserDetail

type UserDetail struct {
	Star  string
	Gbit  string
	Score string
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL