View Single Post
Old 10-02-2010, 10:38 AM   #220
aleyx
Addict
aleyx can self-interpret dreams as they happen.aleyx can self-interpret dreams as they happen.aleyx can self-interpret dreams as they happen.aleyx can self-interpret dreams as they happen.aleyx can self-interpret dreams as they happen.aleyx can self-interpret dreams as they happen.aleyx can self-interpret dreams as they happen.aleyx can self-interpret dreams as they happen.aleyx can self-interpret dreams as they happen.aleyx can self-interpret dreams as they happen.aleyx can self-interpret dreams as they happen.
 
Posts: 250
Karma: 20386
Join Date: Sep 2010
Location: France
Device: Bookeen Diva, Kobo Clara BW
Quote:
Originally Posted by AtomicDryad View Post
Regarding modules and commandline, there's also the question about what to do with url arguments. As is, for a new source plugin one must edit arg.inc.php and add a regexp. The following way of doing it would remove that need...the idea is real modularity; being able to drop in any valid .php in the source directory without editing the base program.
Migrating to OO will ease much of it. We'd start by including everything we need, from codecs to sources to global classes and basic includes:

PHP Code:
    $includes_paths INCLUDE_DIR."/{inc,codec,source}/*.{class,inc,codec,source}.php";
    foreach (
glob($includes_pathsGLOB_BRACE ) as $include_file) {
        require_once(
$include_file);
    } 
All source-specific configuration would be contained in one object, like FfmlSource, defined in "ffml.source.php", and be accessible from a Sources factory class.

If we have an URL but no source in the arguments, we'll be able to invoke Sources::getSource($url); and get back an object Source that will tell us everything we need to know about the URL: how to extract the story, its meta, whether the URL contains a story or a list of stories, etc.

However, not all inputs will be URLs, so I think it'd be better to allow the use of the same argument format for sources as for codecs:

Code:
./fflag --some-option --other-option=/some/file -o /some/dir -i ffml:id1,id2 -i siye:id3,id4 -i ficpress:id5,id6 -f html:option1,option2 -f epub:option3,option4 url1 url2
Processing this, we'd have your arrays:
Spoiler:

Code:
array(
    'ffml' => array( 'id1', 'id2', 'url1' ),
    'siye' => array( 'id3', 'id4', 'url2' ),
    'ficpress' => array ( 'id5', 'id6' )
)

Processing the array:
Spoiler:

PHP Code:
$stories = array();
foreach ( 
$processing_list as $source => $ids_list ) {
    
Log::debug("Processing {$source->name} stories and/or lists.");
    
$source Source::getSource($source);
    foreach ( 
$ids_list as $id ) {
        
Log::debug("Now processing $id");
        if ( 
$source->isList($id) ) {
            
array_merge($stories$source->getList($url);
        }
        else {
            
$story $source->getStory$id );
            
$stories[] = $story;
        }
        
Log::debug("$id: done");
    }
    
Log::debug($source->name.": done.");
}
foreach ( 
$stories as $story ) {
    
Log::info("We've found and are now exporting: ".$story->__toString());
    
$story->export();
    
Log::info($story->__toString()." has been exported to ".$story->filename);



The getStory() function will know the difference between an ID and an URL, and go from there. Idem for the export() function, which will be able to get from the opts what are the output formats and options, and call Codec instances accordingly.

Erayd, would it be possible to set up a bugzilla or something? We're getting technical on many different issues, and I don't know if a forum thread is the best place?

We'll need to document the code, too. How does everyone feel about Doxygen?

N.
aleyx is offline   Reply With Quote