Comments (3)
I experienced the same issue, thinking using /sync/dropbox/download
would synchronize. I actually only adds files.
To empty the post
folder (ftp side) at the beginning of the sync would solve the problem for dropbox-exclusive users but would cause damage for someone who uses Dropbox AND ftp...
Since I plan to use Dropbox only to post on my blog, I will add this flush-the-post-folder-before-syncing command. Could you give me a clue on which php file/function it is more relevant to write it?
from justwriting.
unlink,delete a file
from justwriting.
Hi,
I added two stuff to the file application/controllers/dropbox.php
:
-
The feature to add files from from dropbox only if it matches certain extensions.
-
Removing the blog post when the corresponding markdown file is removed from the dropbox folder
It concerns only the function
download()
so the update is pretty quick
public function download($value='')
{
$debug = false;
if(isset($_GET['challenge'])){
echo $_GET['challenge'];exit;
}
if(isset($_GET['debug'])){
$debug = true;
}
set_time_limit(60*30);
$this->load->library('dropbox_lib');
$client = $this->dropbox_lib->getClient();
if ($client === false) {
header("Location: /sync/dropbox");
exit;
}
$cursor = null;
$cursor_filename = FCPATH."posts/cursor.txt";
if(file_exists($cursor_filename)){
$cursor = file_get_contents($cursor_filename);
}
if(empty($cursor)){
$cursor = null;
}
$changes = $client->getDelta($cursor);
if($debug){
print_r($changes);
}
if(!empty($changes))
{
foreach($changes['entries'] as $row){
$localFilename = "posts".$row[0];
$filename = FCPATH.$localFilename;
// extract the extension to filter the dropbox -> ftp transfert
$ext = pathinfo($filename, PATHINFO_EXTENSION);
$authorizedExt = array("md", "txt", "markdown");
if(in_array($ext, $authorizedExt)){
if($row[1]['is_dir'] ){
if(!file_exists($filename)){
mkdir($filename,0777,true);
}
}else{
if(!file_exists(dirname($filename))){
mkdir(dirname($filename),0777,true);
}
if(!empty($row[1])){ // means "a file was added to Dropbox"
$fd = fopen($filename, "wb");
$metadata = $client->getFile($row[0], $fd);
fclose($fd);
print_r($metadata);
}else{ // mean "the file was removed from Dropbox"
unlink( $localFilename);
}
}
} // endif authorized ext
}
$cursor = $changes['cursor'];
if($cursor){
$fd = fopen($cursor_filename, "wb");
fwrite($fd,$cursor);
fclose($fd);
}
}
}
(Sorry for the poor indentation)
It would be cooler to place the accepted extension list ($authorizedExt) to settings.php
, but I does the job like that...
Cheers.
from justwriting.
Related Issues (20)
- 链接dropbox后,右侧空白
- 提个PR? HOT 1
- 建议支持 google drive
- Just Writing support latex math equations HOT 1
- 无法同步
- 重新部署justwriting
- [Security] XSS in application/controllers/dropbox.php
- VPS主页能打开,页面404 HOT 8
- Thank you for your share
- 怎样在windows上同步文章? HOT 3
- linux 跳转页面报404 HOT 14
- 我使用了你的justwriting,非常棒! HOT 1
- JustWriting 做得很棒,反馈个小问题 HOT 3
- justwriting很好用 HOT 1
- 我写的JustWriting的教程 HOT 1
- 强烈建议增加搜索功能 HOT 1
- Link to drafts
- Planned posts
- 部署代码中遇到问题: -1:fail to get xml content.
- Markdown 语法似乎支持得不完整
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from justwriting.