Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
executable file
·
108 lines (96 loc) · 2.79 KB

File metadata and controls

executable file
·
108 lines (96 loc) · 2.79 KB
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
//
// CodeFile.m
// Coding_iOS
//
// Created by 王 原闯 on 14/10/29.
// Copyright (c) 2014年 Coding. All rights reserved.
//
#import "CodeFile.h"
@implementation CodeFile
+ (CodeFile *)codeFileWithRef:(NSString *)ref andPath:(NSString *)path{
CodeFile *codeFile = [[CodeFile alloc] init];
codeFile.ref = ref;
codeFile.path = path;
return codeFile;
}
+ (CodeFile *)codeFileWithMDStr:(NSString *)md_html{
CodeFile *codeFile = [self codeFileWithRef:@"" andPath:@"README"];
CodeFile_RealFile *file = [CodeFile_RealFile new];
file.mode = @"file";
file.lang = @"markdown";
file.preview = md_html;
codeFile.file = file;
return codeFile;
}
+ (CodeFile *)codeFileToCommitWithRef:(NSString *)ref andPath:(NSString *)path name:(NSString *)name data:(NSString *)data message:(NSString *)message headCommit:(Commit *)headCommit{
CodeFile *codeFile = [self codeFileWithRef:ref andPath:path];
codeFile.editName = name;
codeFile.editData = data;
codeFile.editMessage = message;
codeFile.headCommit = headCommit;
return codeFile;
}
+ (CodeFile *)codeFileWithLocalURL:(NSURL *)localURL{
CodeFile *codeFile = [self new];
CodeFile_RealFile *file = [CodeFile_RealFile new];
file.mode = @"file";
NSStringEncoding enc;
file.data = [NSString stringWithContentsOfURL:localURL usedEncoding:&enc error:nil];
file.lang = localURL.ea_lang ?: @"";
codeFile.file = file;
return codeFile;
}
- (NSString *)path{
if (!_path) {
_path = @"";
}
return _path;
}
- (NSString *)ref{
if (!_ref) {
_ref = @"master";
}
return _ref;
}
- (NSString *)editData{
if (!_editData) {
_editData = _file.data.copy;
}
return _editData;
}
- (NSString *)editName{
if (!_editName) {
_editName = _file.name.copy;
}
return _editName;
}
- (NSString *)editMessage{
if (!_editMessage) {
_editMessage = [NSString stringWithFormat:@"update %@", _path];
}
return _editMessage;
}
- (NSDictionary *)toEditParams{
NSMutableDictionary *params = @{}.mutableCopy;
params[@"content"] = self.editData;
params[@"message"] = self.editMessage;
params[@"lastCommitSha"] = self.headCommit.commitId;
return params;
}
- (NSDictionary *)toDeleteParams{
NSMutableDictionary *params = @{}.mutableCopy;
params[@"message"] = [NSString stringWithFormat:@"delete: %@", self.file.name];
params[@"lastCommitSha"] = self.headCommit.commitId;
return params;
}
- (NSDictionary *)toCreateParams{
NSMutableDictionary *params = @{}.mutableCopy;
params[@"title"] = self.editName;
params[@"content"] = self.editData;
params[@"message"] = self.editMessage;
params[@"lastCommitSha"] = self.headCommit.commitId;
return params;
}
@end
@implementation CodeFile_RealFile
@end
Morty Proxy This is a proxified and sanitized view of the page, visit original site.