## -- Misc Configs -- ##stash_dir="_stash"# directory to stash posts for speedy generationfull_stash_dir="#{source_dir}/#{stash_dir}"# full path for stash dirstash_root_dir="_stash_root"# directory to stash pages (in /source/)full_stash_root_dir="#{source_dir}/#{stash_root_dir}"# full path for stash_root dirroot_stashes=['Your-Page']# directories to be stashed in /source/# usage rake isolate[my-post]desc"Move all other posts than the one currently being worked on to a temporary stash location (stash) so regenerating the site happens much more quickly."task:isolate,:filenamedo|t,args|ifargs.filenamefilename=args.filenameelsefilename=Dir.glob("#{source_dir}/#{posts_dir}/*.#{new_post_ext}").sort_by{|f|File.mtime(f)}.lastendiffilename==nilputs""puts"There is no markdown file (*.#{new_post_ext}) in #{source_dir}/#{posts_dir}."exit1endputs"## Stashing other posts than #{filename}"FileUtils.mkdir(full_stash_dir)unlessFile.exist?(full_stash_dir)Dir.glob("#{source_dir}/#{posts_dir}/*")do|post|ifpost.include?(filename)p"Remaining #{post}..."elseFileUtils.mvpost,full_stash_direndendFileUtils.mkdir(full_stash_root_dir)unlessFile.exist?(full_stash_root_dir)ifdefined?root_stashes==nilifroot_stashes.class==StringFileUtils.mv"#{source_dir}/#{root_stashes}",full_stash_root_direlsifroot_stashes.class==Arrayfordinroot_stashesdoFileUtils.mv"#{source_dir}/#{d}",full_stash_root_direndendendsystem"touch .isolated"enddesc"Move all stashed posts back into the posts directory, ready for site generation."task:integratedoFileUtils.mvDir.glob("#{full_stash_dir}/*"),"#{source_dir}/#{posts_dir}/"FileUtils.mvDir.glob("#{full_stash_root_dir}/*"),"#{source_dir}/"system"rm -f .isolated"system"touch .integrated"end
# Execution part {{{_s_is_exec=1_sf_check_args_first(){# {{{while[$#-gt0];docase$1in"-h"|"-N"|"-m"|"-p"|"-F"|"-v")_s_is_exec=2;shift;;"-n")_s_is_exec=0;shift;;"-c")_SENTAKU_CHILD=1;shift;;*)break;;esacdone}# }}}_sf_check_args_first"$@"# Execute if stdin is available, or any of help/file/push is onif[$_s_is_exec-ne0];thenif[-p/dev/stdin]||[$_s_is_exec-eq2];then_sf_main"$@"fifi# Clean upunset_s_is_exec
# }}}
#!/usr/bin/env python#Copyright (c) 2013 rcmdnkimportosimportsysimporthttplib2fromoauth2client.fileimportStoragefromoauth2client.toolsimportrunfromoauth2client.clientimportOAuth2WebServerFlowfromapiclient.discoveryimportbuilddefmain(uselist='',items=''):# Authentaationstorage=Storage(os.path.expanduser('~/.gtask_oauth'))credentials=storage.get()ifcredentialsisNoneorcredentials.invalid:credentials=run(OAuth2WebServerFlow(client_id='326384869607-9c57sseqij1vpes16ect83irq490pn8c.apps.googleusercontent.com',client_secret='h0vi7XXzU3DRJyEa2aYFPRcm',scope=['https://www.googleapis.com/auth/tasks','https://www.googleapis.com/auth/tasks.readonly'],user_agent='gtaskslist/1.0',),storage)http=httplib2.Http()http=credentials.authorize(http)service=build('tasks','v1',http=http)# Get task liststasklists=service.tasklists().list().execute()fortlintasklists['items']:# Check list nameifuselist!=''andtl['title']!=uselist:continue# Get taskstasks=service.tasks().list(tasklist=tl['id']).execute()fortintasks['items']:ttitle=t['title']ifttitle=='':continueuseflag=0iflen(items)==0oritems[0]=='':useflag=1else:foriinitems:ifttitle.find(i)!=-1:useflag=1breakifuseflag==1:printttitle.encode('utf_8')if__name__=='__main__':# Get command line optionsfromoptparseimportOptionParserusage='''usage: %prog [-opts] arg1 arg2 If arg1 arg2... are given, only tasks which include these words (ORed) will be listed (combined with -i) If you have not installed google-api-python-client, follow: https://developers.google.com/api-client-library/python/start/installation '''parser=OptionParser(usage)parser.add_option('-l','--list',action='store',dest='uselist',default='',help='If \'USELIST\' is not an empty, tasks will be searched for only from the given list. [default: %default]')parser.add_option('-i','--item',action='store',dest='item',default='',help='If \'ITEM\' is not an empty, only tasks which contains given item are listed up. Multiple words can be given by using \',\' as a separator. [default: %default]')(opts,args)=parser.parse_args()# Set parametersuselist=opts.uselistitems=opts.item.split(',')foriinargs:items.append(i)# Run main functionmain(uselist,items)