forked from luna/vim-rana-local
Compare commits
No commits in common. "master" and "master" have entirely different histories.
3 changed files with 27 additions and 23 deletions
29
README.md
29
README.md
|
@ -1,30 +1,37 @@
|
||||||
# vim-rana
|
[](https://github.com/wakatime/vim-wakatime#installation)
|
||||||
|
[](https://github.com/wakatime/vim-wakatime#installation)
|
||||||
|
[](https://github.com/wakatime/vim-wakatime#installation)
|
||||||
|
[](https://github.com/wakatime/vim-wakatime#installation)
|
||||||
|
|
||||||
|
|
||||||
|
# vim-wakatime
|
||||||
|
|
||||||
Quantify your coding inside Vim.
|
Quantify your coding inside Vim.
|
||||||
|
|
||||||
**This is a fork of vim-wakatime. Rana is not affiliated with WakaTime.**
|
|
||||||
|
|
||||||
**Rana is a reverse-engineered WakaTime server.** https://github.com/lnyaa/rana
|
|
||||||
|
|
||||||
Installation
|
Installation
|
||||||
------------
|
------------
|
||||||
|
|
||||||
1. With [Vundle](https://github.com/gmarik/vundle): `echo "Plugin 'https://gitdab.com/lavatech/vim-rana'" >> ~/.vimrc && vim +PluginInstall`
|
1. With [Vundle](https://github.com/gmarik/vundle): `echo "Plugin 'wakatime/vim-wakatime'" >> ~/.vimrc && vim +PluginInstall`
|
||||||
|
|
||||||
Or with [Pathogen](https://github.com/tpope/vim-pathogen): `cd ~/.vim/bundle && git clone https://gitdab.com/lavatech/vim-rana.git`
|
Or with [Pathogen](https://github.com/tpope/vim-pathogen): `cd ~/.vim/bundle && git clone git://github.com/wakatime/vim-wakatime.git`
|
||||||
|
|
||||||
Or with [Vim-plug](https://github.com/junegunn/vim-plug): add `Plug 'https://gitdab.com/lavatech/vim-rana'` to .vimrc file. While in vim reload .vimrc with `:so ~/.vimrc` or restart vim, enter
|
Or with [Vim-plug](https://github.com/junegunn/vim-plug): add `Plug 'wakatime/vim-wakatime'` to .vimrc file. While in vim reload .vimrc with `:so ~/.vimrc` or restart vim, enter
|
||||||
`:PlugInstall`.
|
`:PlugInstall`.
|
||||||
|
|
||||||
2. Enter your [api key](https://wakatime.com/settings#apikey), then press `enter`.
|
2. Enter your [api key](https://wakatime.com/settings#apikey), then press `enter`.
|
||||||
|
|
||||||
3. Enter your Rana instance's base URL on the `~/.wakatime.cfg` file. Put it on the `base_url` field. e.g `base_url=https://rana.discordapp.io`
|
3. Use Vim and your coding activity will be displayed on your [WakaTime dashboard](https://wakatime.com).
|
||||||
|
|
||||||
4. Use Vim and your coding activity will be displayed on your preffered rana instance.
|
|
||||||
|
|
||||||
Note: WakaTime depends on [Python](http://www.python.org/getit/) being installed to work correctly.
|
Note: WakaTime depends on [Python](http://www.python.org/getit/) being installed to work correctly.
|
||||||
|
|
||||||
|
|
||||||
|
Screen Shots
|
||||||
|
------------
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
|
||||||
Configuring
|
Configuring
|
||||||
-----------
|
-----------
|
||||||
|
|
||||||
|
@ -74,7 +81,7 @@ For more general troubleshooting info, see the [wakatime-cli Troubleshooting Sec
|
||||||
Uninstalling
|
Uninstalling
|
||||||
------------
|
------------
|
||||||
|
|
||||||
1. Remove `Plugin 'lavatech/vim-rana'` from your `.vimrc` file.
|
1. Remove `Plugin 'wakatime/vim-wakatime'` from your `.vimrc` file.
|
||||||
|
|
||||||
2. Run in terminal: `rm ~/.wakatime.*`.
|
2. Run in terminal: `rm ~/.wakatime.*`.
|
||||||
|
|
||||||
|
|
|
@ -38,11 +38,6 @@ except ImportError: # pragma: nocover
|
||||||
sys.exit(UNKNOWN_ERROR)
|
sys.exit(UNKNOWN_ERROR)
|
||||||
|
|
||||||
|
|
||||||
def _make_url(configs, path):
|
|
||||||
base_url = configs.get('settings', 'base_url', fallback=None) or 'https://api.wakatime.com'
|
|
||||||
return '%s%s' % (base_url, path)
|
|
||||||
|
|
||||||
|
|
||||||
def send_heartbeats(heartbeats, args, configs, use_ntlm_proxy=False):
|
def send_heartbeats(heartbeats, args, configs, use_ntlm_proxy=False):
|
||||||
"""Send heartbeats to WakaTime API.
|
"""Send heartbeats to WakaTime API.
|
||||||
|
|
||||||
|
@ -52,7 +47,9 @@ def send_heartbeats(heartbeats, args, configs, use_ntlm_proxy=False):
|
||||||
if len(heartbeats) == 0:
|
if len(heartbeats) == 0:
|
||||||
return SUCCESS
|
return SUCCESS
|
||||||
|
|
||||||
api_url = _make_url(configs, '/api/v1/users/current/heartbeats.bulk')
|
api_url = args.api_url
|
||||||
|
if not api_url:
|
||||||
|
api_url = 'https://rana.discordapp.io/api/v1/users/current/heartbeats.bulk'
|
||||||
log.debug('Sending heartbeats to api at %s' % api_url)
|
log.debug('Sending heartbeats to api at %s' % api_url)
|
||||||
timeout = args.timeout
|
timeout = args.timeout
|
||||||
if not timeout:
|
if not timeout:
|
||||||
|
@ -166,7 +163,7 @@ def send_heartbeats(heartbeats, args, configs, use_ntlm_proxy=False):
|
||||||
return AUTH_ERROR if code == 401 else API_ERROR
|
return AUTH_ERROR if code == 401 else API_ERROR
|
||||||
|
|
||||||
|
|
||||||
def get_time_today(args, configs, use_ntlm_proxy=False):
|
def get_time_today(args, use_ntlm_proxy=False):
|
||||||
"""Get coding time from WakaTime API for given time range.
|
"""Get coding time from WakaTime API for given time range.
|
||||||
|
|
||||||
Returns total time as string or `None` when unable to fetch summary from
|
Returns total time as string or `None` when unable to fetch summary from
|
||||||
|
@ -174,7 +171,7 @@ def get_time_today(args, configs, use_ntlm_proxy=False):
|
||||||
fetch summary.
|
fetch summary.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
url = _make_url(configs, '/api/v1/users/current/summaries')
|
url = 'https://rana.discordapp.io/api/v1/users/current/summaries'
|
||||||
timeout = args.timeout
|
timeout = args.timeout
|
||||||
if not timeout:
|
if not timeout:
|
||||||
timeout = 60
|
timeout = 60
|
||||||
|
@ -222,7 +219,7 @@ def get_time_today(args, configs, use_ntlm_proxy=False):
|
||||||
verify=ssl_verify)
|
verify=ssl_verify)
|
||||||
except RequestException:
|
except RequestException:
|
||||||
if should_try_ntlm:
|
if should_try_ntlm:
|
||||||
return get_time_today(args, configs, use_ntlm_proxy=True)
|
return get_time_today(args, use_ntlm_proxy=True)
|
||||||
|
|
||||||
session_cache.delete()
|
session_cache.delete()
|
||||||
if log.isEnabledFor(logging.DEBUG):
|
if log.isEnabledFor(logging.DEBUG):
|
||||||
|
@ -236,7 +233,7 @@ def get_time_today(args, configs, use_ntlm_proxy=False):
|
||||||
|
|
||||||
except: # delete cached session when requests raises unknown exception
|
except: # delete cached session when requests raises unknown exception
|
||||||
if should_try_ntlm:
|
if should_try_ntlm:
|
||||||
return get_time_today(args, configs, use_ntlm_proxy=True)
|
return get_time_today(args, use_ntlm_proxy=True)
|
||||||
|
|
||||||
session_cache.delete()
|
session_cache.delete()
|
||||||
if log.isEnabledFor(logging.DEBUG):
|
if log.isEnabledFor(logging.DEBUG):
|
||||||
|
@ -267,7 +264,7 @@ def get_time_today(args, configs, use_ntlm_proxy=False):
|
||||||
return None, API_ERROR
|
return None, API_ERROR
|
||||||
else:
|
else:
|
||||||
if should_try_ntlm:
|
if should_try_ntlm:
|
||||||
return get_time_today(args, configs, use_ntlm_proxy=True)
|
return get_time_today(args, use_ntlm_proxy=True)
|
||||||
|
|
||||||
session_cache.delete()
|
session_cache.delete()
|
||||||
log.debug({
|
log.debug({
|
||||||
|
|
|
@ -43,7 +43,7 @@ def execute(argv=None):
|
||||||
setup_logging(args, __version__)
|
setup_logging(args, __version__)
|
||||||
|
|
||||||
if args.today:
|
if args.today:
|
||||||
text, retval = get_time_today(args, configs)
|
text, retval = get_time_today(args)
|
||||||
if text:
|
if text:
|
||||||
print(text)
|
print(text)
|
||||||
return retval
|
return retval
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue